题目描述
Problem Background
cbw, known as the best in the world, ruled the entire universe in the year 8102 as the chairman. After that, he began to enjoy his leisure life and invited his friends to play games with him every day. cbw wanted to show his approachability, so even zhouwc, who is a novice, had the chance to play games with cbw.
Problem Description
The game is as follows:
Given two numbers $x$ and $y$, and a modulus $p$.
cbw has the number $x$, and zhouwc has the number $y$.
The first round: $x \leftarrow (x + y) \bmod p$.
The second round: $y \leftarrow (x + y) \bmod p$.
The third round: $x \leftarrow (x + y) \bmod p$.
The fourth round: $y \leftarrow (x + y) \bmod p$.
And so on...
If $x$ reaches $0$ first, cbw wins. If $y$ reaches $0$ first, zhouwc wins. If neither $x$ nor $y$ can reach $0$, the game ends in a draw.
cbw, wanting to maintain his dignity as the chairman, wants to know the result of the game in advance and possibly manipulate the outcome. Therefore, he hopes you can tell him the result.
Input Format
There are multiple sets of data.
The first line: $T$ and $p$ indicate there are $T$ sets of data with the modulus $p$.
The following $T$ lines, each containing two numbers $x$ and $y$.
Output Format
A total of $T$ lines.
$1$ indicates cbw wins, $2$ indicates zhouwc wins, and error indicates a draw.
Sample Input and Output
Sample Input #1
1 10
1 3
Sample Output #1
error
Sample Input #2
1 10
4 5
Sample Output #2
1
Notes
$1 \leq T \leq 200$.
$1 \leq x, y, p \leq 10000$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分