Codeforces Beta Round 36
D
使用国际象棋棋子的全新游戏
New Game with a Chess Piece
Codeforces
2300
原题
← CE →

使用国际象棋棋子的全新游戏AI (CI翻译)

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.

Petya 和 Vasya 正在发明一种新游戏。这个游戏需要一块矩形棋盘和一个国际象棋棋子。游戏开始时,棋子位于棋盘的左上角。两名玩家轮流移动棋子。每次操作中,棋子可以向右移动一格、向下移动一格,或者沿右下方向斜着跳过 $*k*$ 格。无法移动棋子的玩家输掉游戏。AI (CI翻译)

image

imageAI (CI翻译)

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.

两人还没有想好该给这个游戏取什么名字,也没有决定棋盘的最佳大小。你的任务是编写一个程序,根据棋盘的大小判断游戏的结果。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first input line contains two integers $*t*$ and $*k*$ ($1 ≤ *t* ≤ 20$, $1 ≤ *k* ≤ 10^{9}$). Each of the following $*t*$ lines contains two numbers $*n*$, $*m*$ — the board’s length and width ($1 ≤ *n*, *m* ≤ 10^{9}$).

第一行输入包含两个整数 $*t*$ 和 $*k*$($1 ≤ *t* ≤ 20$,$1 ≤ *k* ≤ 10^{9}$)。接下来的 $*t*$ 行中,每行包含两个数 $*n*$、$*m*$,分别表示棋盘的长度和宽度($1 ≤ *n*, *m* ≤ 10^{9}$)。AI (CI翻译)

Output

输出格式

AI (CI翻译)

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

输出 $*t*$ 行,分别表示每块棋盘上的游戏结果。如果先手获胜,输出 «+»;否则输出 «-»。AI (CI翻译)

样例

Input #1
10 2
1 1
1 2
2 1
2 2
1 3
2 3
3 1
3 2
3 3
4 3
Output #1
-
+
+
-
-
+
-
+
+
+
InputCopy OutputCopy
题目信息
题号
36D
时间限制
2 s
内存限制
64 MB
标签
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。