CF2060A.Fibonacciness

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Fibonacciness

There is an array of 55 integers. Initially, you only know a1,a2,a4,a5a_1,a_2,a_4,a_5. You may set a3a_3 to any positive integer, negative integer, or zero. The Fibonacciness of the array is the number of integers ii (1i31 \leq i \leq 3) such that ai+2=ai+ai+1a_{i+2}=a_i+a_{i+1}. Find the maximum Fibonacciness over all integer values of a3a_3.

Input

The first line contains an integer tt (1t5001 \leq t \leq 500) — the number of test cases.

The only line of each test case contains four integers a1,a2,a4,a5a_1, a_2, a_4, a_5 (1ai1001 \leq a_i \leq 100).

Output

For each test case, output the maximum Fibonacciness on a new line.

Note

In the first test case, we can set a3a_3 to 22 to achieve the maximal Fibonacciness of 33.

In the third test case, it can be shown that 22 is the maximum Fibonacciness that can be achieved. This can be done by setting a3a_3 to 1818.

Samples

6
1 1 3 5
1 3 2 1
8 10 28 100
100 1 100 1
1 100 1 100
100 100 100 100
3
2
2
1
1
2

在线编程 IDE

建议全屏模式获得最佳体验