Chef has an array A = (A1, A2, ..., AN), which has N integers in it initially. Chef found that for i ≥ 1, if Ai > 0, Ai+1 > 0, and Ai+2 exists, then he can decrease both Ai, and Ai+1 by one and increase Ai+2 by one. If Ai+2 doesn't exist, but Ai > 0, and Ai+1 > 0, then he can decrease both Ai, and Ai+1 (which will be the currently last two elements of the array) by one and add a new element at the end, whose value is 1.
Now Chef wants to know the number of different arrays that he can make from A using this operation as many times as he wishes. Help him find this, and because the answer could be very large, he is fine with you reporting the answer modulo 109+7.
Two arrays are same if they have the same number of elements and if each corresponding element is the same. For example arrays (2,1,1) and (1,1,2) are different. 

-----Input-----
- The first line of the input contains a single integer T denoting the number of test cases.
- The first line contains a single integer N denoting the initial number of elements in A.
- The second line contains N space-separated integers: A1, A2, ... , AN. 

-----Output-----
For each test case, output answer modulo 109+7 in a single line. 

-----Constraints-----
- 1 ≤ T ≤ 5
- 1 ≤ N ≤ 50
- 0 ≤ Ai ≤ 50

-----Subtasks-----
- Subtask 1 (20 points) : 1 ≤ N ≤ 8, 0 ≤ Ai ≤ 4
- Subtask 2 (80 points) : Original constraints

-----Example-----
Input:
3
3
2 3 1
2
2 2
3
1 2 3

Output:
9
4
9

-----Explanation-----
Example case 1.
We'll list the various single steps that you can take (ie. in one single usage of the operation):
- (2, 3, 1) → (2, 2, 0, 1)
- (2, 2, 0, 1) → (1, 1, 1, 1)
- (1, 1, 1, 1) → (1, 1, 0, 0, 1)
- (1, 1, 0, 0, 1) → (0, 0, 1, 0, 1)
- (1, 1, 1, 1) → (1, 0, 0, 2)
- (1, 1, 1, 1) → (0, 0, 2, 1)
- (2, 3, 1) → (1, 2, 2)
- (1, 2, 2) → (0, 1, 3)

So all the arrays you can possibly get are: 
(2, 3, 1), (2, 2, 0, 1), (1, 1, 1, 1), (1, 1, 0, 0, 1), (0, 0, 1, 0, 1), (1, 0, 0, 2), (0, 0, 2, 1), (1, 2, 2), and (0, 1, 3)
Since there are 9 different arrays that you can reach, the answer is 9.

```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 = 'from sys import stdin\n \nmod = 10**9 + 7\nmax_val = 135\n\ncache2 = [[0]*max_val for _ in range(max_val)]\ndone = [[False]*max_val for _ in range(max_val)]\ndef f2(x, y):\n\tif done[x][y]:\n\t\tres = cache2[x][y]\n\telif x == 0 or y == 0:\n\t\tres = 1\n\t\tcache2[x][y] = res\n\t\tdone[x][y] = True\n\telif x > y:\n\t\tres = f2(y, y)\n\t\tcache2[x][y] = res\n\t\tdone[x][y] = True\n\telse:\n\t\tres = sum(f2(y-i, i) for i in range(x+1))\n\t\tcache2[x][y] = res\n\t\tdone[x][y] = True\n\treturn res % mod\n \ndef solve():\n\tn = int(stdin.readline().strip())\n\ta = list(map(int, stdin.readline().strip().split()))\n\t\n\tcache = [[[0]*max_val for _ in range(max_val)] for _ in range(51)]\n\tdone = [[[False]*max_val for _ in range(max_val)] for _ in range(51)]\n\tdef f(i, x, y):\n\t\tif done[i][x][y]:\n\t\t\tres = cache[i][x][y]\n\t\telif i == n-1:\n\t\t\tres = 1\n\t\t\tcache[i][x][y] = res\n\t\t\tdone[i][x][y] = True\n\t\telif i == n-2:\n\t\t\tres = f2(x, y)\n\t\t\tcache[i][x][y] = res\n\t\t\tdone[i][x][y] = True\n\t\telif x == 0:\n\t\t\tres = f(i+1, y, a[i+2])\n\t\t\tcache[i][x][y] = res\n\t\t\tdone[i][x][y] = True\n\t\telse:\n\t\t\tk = min(x, y)\n\t\t\tres = 0\n\t\t\tfor z in range(k+1):\n\t\t\t\tres += f(i+1, y-z, a[i+2]+z)\n\t\t\t\tres %= mod\n\t\t\tcache[i][x][y] = res\n\t\t\tdone[i][x][y] = True\t\n\t\treturn res % mod\n\t\n\tprint(f(0, a[0], a[1]) if n >= 2 else 1)\n \nt = int(stdin.readline().strip())\nfor _ in range(t):\n\tsolve()'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 47631543