Rakesh has built a model rocket and wants to test how stable it is. He usually uses a magic box which runs some tests on the rocket and tells if it is stable or not, but his friend broke it by trying to find out how stable he is (very delicate magic indeed). The box only gives a polynomial equation now which can help Rakesh find the stability (a failsafe by the manufacturers). 

Rakesh reads the manual for the magic box and understands that in order to determine stability, he needs to take every other term and put them in two rows. Eg. If the polynomial is:
10 x^4 + 12 x^3 + 4 x^2 + 5 x + 3, the first two rows will be: 

Row 1: 10       4       3

Row 2: 12       5       0

For all other rows, the nth element of the rth row is found recursively by multiplying the 1st element of the (r-1)th row and (n+1)th element of the (r-2)th row and subtracting it with 1st element of the (r-2)th row multiplied by (n+1)th element of the (r-1)th row.

So Row 3 will be (12 * 4 - 10 * 5)   (12 * 3 - 10 * 0)

Row 3: -2           36      0

Row 4: -442        0       0

Row 5: -15912    0       0

There will not be any row six (number of rows = maximum power of x + 1)

The rocket is stable if there are no sign changes in the first column. 

If all the elements of the rth row are 0, replace the nth element of the rth row by the nth element of the (r-1)th row multiplied by (maximum power of x + 4 - r - 2n).

If the first element of any row is 0 and some of the other elements are non zero, the rocket is unstable.

Can you help Rakesh check if his rocket is stable?

Input Format:

1. First row with number of test cases (T).

2. Next T rows with the coefficients of the polynomials for each case (10 12 4 5 3 for the case above).

Output Format:

1. "1" if stable (without "")

2. "0" if unstable (without "")

Sample Input: 

1

10 12 4 5 3

Sample Output:

0

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'def SR(coeff):\r\n    size = len(coeff) # Please work out what if n is small no, like 1 or 2\r\n    #print("No. of rows will form is", size)\r\n    max_power = size - 1\r\n    Arr = [] # 2x2\r\n    row1 = coeff[0::2]\r\n    row2 = coeff[1::2]\r\n    #print(\'row1: \', row1, \'\\n\', \'row2: \', row2)\r\n    ln = len(row1) #don\'t change this value\r\n    if size%2 != 0: # if n is odd\r\n        row2.append(0) # to balance row1 and row2\r\n    # add 1 empty element in each row for safety\r\n    row1.append(0) \r\n    row2.append(0) \r\n    Arr.append(row1)\r\n    Arr.append(row2)\r\n    #print(\'start\')\r\n    \r\n    sign = lambda x: 1 if x > 0 else -1  \r\n    s = [sign(row1[0]), sign(row2[0])] # keep track of sign of 1st member of each row\r\n    \r\n    for r in range(2,size):\r\n        Arr.append([0]*(ln+1)) # create a row of empty elements\r\n        #print(r+1,\'th row created\', Arr)\r\n        \r\n        for n in range(ln): #generate value of nth element of rth row\r\n            #print(n+1, \'th element to fill\')\r\n            # below mean, (12 * 4) - (10*5)\r\n            Arr[r][n] = (Arr[r-1][0] * Arr[r-2][n+1]) - (Arr[r-2][0] * Arr[r-1][n+1])\r\n            \r\n        \r\n        s.append(sign(Arr[r][0]))\r\n        #print("  Array Print:  ")\r\n        #for k in Arr: print(k) \r\n        \r\n    \'\'\' If all the element of that row is zero case\r\n    then nth element = nth element of its previous row *\r\n    ((max. power of x) - 4 - r - 2n ) \'\'\'\r\n    for i in range(len(Arr)): # i th row in Arr\r\n        if list(set(Arr[i])) == [0]:       \r\n            #print(Arr[i])\r\n            for n in range(len(Arr[i])):\r\n                # I think that make sense\r\n                Arr[i][n] = (Arr[i-1][n] * (max_power + 4 - (i+1) - (2*(n+1))))\r\n                \r\n        elif Arr[i][0] == 0:\r\n            return 0 \r\n        \r\n    \'\'\' check if sign change \'\'\'\r\n    if len(set(s)) == 1: # no sign change\r\n        return 1\r\n    else: # sign change\r\n        return 0\r\n\r\n            \r\n          \r\nT = int(input())\r\n#coeff = [10, 12, 4, 5, 3, 2]\r\nfor t in range(T):\r\n    coeff = [int(x) for x in input().split()] # [10, 12, 4, 5, 3]\r\n    print(SR(coeff))'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13063