Petya和Vasya正在发明一种新的游戏,这种游戏需要一块长方形的棋盘和一个棋子。游戏开始时棋子位于棋盘的左上角,由两名玩家轮流移动棋子。每一次移动,棋子可以向右移动一格,或者向下移动一格,或者斜向右下方移动k格。最后无法再移动棋子的玩家输掉游戏。他们还没想好这个游戏叫什么名字,也没想好棋盘的最佳尺寸。你的任务是编写一个程序,能够根据棋盘的大小判断游戏的结果。
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.
The guys havn'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.
输入的第一行包含两个整数t和k(1<=t<=20,1<=k<=109)。
接下来的t行每行描述一个棋盘,用两个数字n和m分别表示每个棋盘的长度和宽度(1<=n,m<=109)。
输出共t行,每行表示一个棋盘的胜负情况。如果第一位玩家获胜输出"+
",否则输出"-
"。
------------------分割线----------------------
本翻译参考了原@pushinl 的翻译,并对于英文原文作出了更有助于理解题意的一些改动。在此感谢@pushinl 提供的原翻译。