Hello!
Tomorrow (the 3rd of November) will held the Nothern Subregion Quarterfinal 2012 in the Northeastern European Region.
I think, it will be very interesting to watch the "battle" between teams, because in our quarterfinal participate 3 persons from the top10 in Codeforces rating. And jury made all to make this quaterfinal very interesting and unpredictable.
Also, don't forget, that you can participate in Yandex.Contest.







. That can be computed by modulo p using the fast-power algorithm.
.
. (This is AM-GM inequality.
.
. Squaring both sides we get
, but we want to
. This means, that
.
, this means that for each
, and this mean,
, start DFS and check.
. This means, that
.
и
. The number of iterations -
.