CF2060A Fibonacciness

Description

There is an array of $ 5 $ integers. Initially, you only know $ a_1,a_2,a_4,a_5 $ . You may set $ a_3 $ to any positive integer, negative integer, or zero. The Fibonacciness of the array is the number of integers $ i $ ( $ 1 \leq i \leq 3 $ ) such that $ a_{i+2}=a_i+a_{i+1} $ . Find the maximum Fibonacciness over all integer values of $ a_3 $ .

Input Format

The first line contains an integer $ t $ ( $ 1 \leq t \leq 500 $ ) — the number of test cases. The only line of each test case contains four integers $ a_1, a_2, a_4, a_5 $ ( $ 1 \leq a_i \leq 100 $ ).

Output Format

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

Explanation/Hint

In the first test case, we can set $ a_3 $ to $ 2 $ to achieve the maximal Fibonacciness of $ 3 $ . In the third test case, it can be shown that $ 2 $ is the maximum Fibonacciness that can be achieved. This can be done by setting $ a_3 $ to $ 18 $ .