logo AlgoBeat OnlineJudge
登录 注册

#216108. [ICPC 2021 NAC] Token Game

内存限制:2048 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Alice and Bob are playing a game on board which is a 2-dimensional grid. The board is subdivided into cells. Each cell can be uniquely identified by two integers representing coordinates, each in the range from to .

Two tokens are on the board on distinct cells. Alice starts the game. On each player’s turn, that player chooses one of the tokens, chooses one of the coordinates of the cell it’s on, and reduces that coordinate by some positive amount. The moved token cannot jump over or occupy the same space as the other token. The token must also remain on the board (so both of its coordinates need to stay positive). The first player unable to make a move loses. Note that both players can move either token.

You are given the starting configuration of a number of games. For each of the games, compute the number of initial winning moves available to Alice.

输入格式

The first line of input contains a single integer (), which is the number of games to analyze.

Each of the next lines contains four integers , , and (, and either or holds). This represents the starting configuration of one game, with the tokens at cells and .

输出格式

Output lines. On each line, output a single integer, which is the number of initial winning moves available to Alice for one of the input games. Output them in the order of the input.

样例

样例输入 1

5
6 6 6 3
6 6 2 2
1 6 3 1
3 6 1 3
6 3 1 5

样例输出 1

3
0
1
1
0