time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe cows have just learned what a primitive root is! Given a prime p, a primitive root is an integer x (1 ≤ x < p) such that none of integers x
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Berland a money reform is being prepared. New coins are being introduced. After long economic calculations was decided that the most expensive
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya was given this problem for homework:You are given function (here represents the operation of taking the remainder). His task is to
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to
time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputTomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHaving written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly ktime units for the lunch
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya
time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present — the clock that shows not only
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceedn. Let's denote the
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEach of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEmuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.He wants the fence to be a
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome country is populated by wizards. They want to organize a demonstration.There are n people living in the city, x of them are the wizards who
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFurik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova,
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya