codeforces; solve "Ancient Berland Circus" from Beta Round #1