luogu#P5635. 【CSGRound1】天下第一
【CSGRound1】天下第一
Background
After cbw, the best in the world, ruled the entire universe as chairman in the year 8102, he began to live a relaxed life and invited his friends to play games with him every day. Since cbw wanted to appear approachable, zhouwc, although a “juruo” (weak player), also got the chance to play with cbw.
Problem Description
The game works as follows:
Given two numbers , , and a modulus .
cbw has the number , and zhouwc has the number .
Round 1: .
Round 2: .
Round 3: .
Round 4: .
And so on...
If reaches first, then cbw wins. If reaches first, then zhouwc wins. If neither nor can reach , then it is a draw.
To protect his dignity as chairman, cbw wants to know the result of the game in advance, and he can also take the chance to “do something” behind the scenes. Therefore, he hopes you can tell him the result.
Input Format
There are multiple test cases.
The first line contains and , meaning there are test cases in total, and the modulus for all of them is .
The next lines each contain two numbers .
Output Format
Output lines in total.
means cbw wins, means zhouwc wins, and error means a draw.
1 10
1 3
error
1 10
4 5
1
Hint
.
.
Translated by ChatGPT 5