3404.New Game with a Chess Piece

Time Limit: 1s Memory Limit: 256MB

Petya and Vasya are inventing a new game that requires a rectangular board and one chess piece. At the beginning of the game the piece stands in the upper-left corner of the board. Two players move the piece in turns. Each turn the chess piece can be moved either one square to the right or one square down or jump k squares diagonally down and to the right. The player who can’t move the piece loses.

3404_1.png

The guys haven’t yet thought what to call the game or the best size of the board for it. Your task is to write a program that can determine the outcome of the game depending on the board size.

Input Format(From the terminal/stdin)

The first input line contains two integers t and k (1 \le t \le 20, 1 \le k \le 109). Each of the following t lines contains two numbers n, m - the board’s length and width (1 \le n,m \le 109).

Output Format(To the terminal/stdout)

Output t lines that can determine the outcomes of the game on every board. Write «+» if the first player is a winner, and «-» otherwise.

Sample Input

Copy
10 2
1 1
1 2
2 1
2 2
1 3
2 3
3 1
3 2
3 3
4 3
  · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n

Sample Output

Copy
-
+
+
-
-
+
-
+
+
+
 \n
 \n
 \n
 \n
 \n
 \n
 \n
 \n
 \n
 \n

Submit

请先 登录

© 2025 FAQs