AtCoder Regular Contest 147
F
Again ABC String
AtCoder
⌀ 4016
原题
← E→
翻译中…

Problem Statement

翻译中…

Consider strings of length $N$ consisting of A, B, and C. Among them, find the number of strings that satisfy the following condition, modulo $2$:

翻译中…
  • Let $S_i$ be the string formed by the first $i$ characters of $S$. Also let $A_i$, $B_i$, and $C_i$ be the numbers of A's, B's, and C's in $S_i$, respectively. For all $i$ such that $1 \le i \le N$, the following holds:
  • $A_i-B_i \le X$
    • $B_i-C_i \le Y$
    • $C_i-A_i \le Z$
翻译中…

You have $T$ test cases to solve.

翻译中…

Constraints

翻译中…
  • $1 \le T \le 10$
  • $1 \le N \le 10^9$
  • $0 \le X,Y,Z \le 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

翻译中…

Each case is in the following format:

翻译中…

N X Y Z

翻译中…

Output

翻译中…

For each case, print the answer.

翻译中…

样例

Input #1
1
3 2 1 0
Output #1
0
$8$ strings satisfy the condition: `AAB`,`AAC`,`ABA`,`ABC`,`ACA`,`ACB`,`BAA`,`BAC`. Therefore the answer is $0$.
Input #2
10
1 22 9 92
14 7 74 39
23 50 8 6
93 40 9 60
68 8 47 64
11 68 18 24
3 26 54 8
46 17 90 86
86 76 45 55
80 68 79 62
Output #2
1
0
0
0
1
1
1
0
1
0
题目信息
题号
arc147_f
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。