Chef is a big fan of soccer! He loves soccer so much that he even invented soccer for dogs! Here are the rules of soccer for dogs:
- N$N$ dogs (numbered 1$1$ through N$N$) stand in a line in such a way that for each valid i$i$, dogs i$i$ and i+1$i + 1$ are adjacent.
- Each dog has a skill level, which is either 1$1$ or 2$2$.
- At the beginning of the game, Chef passes a ball to dog 1$1$ (dog 1$1$ receives the ball).
- For each valid i$i$, if dog i$i$ has skill level s$s$, this dog can pass the ball to any dog with number j$j$ such that 1≤|i−j|≤s$1 \le |i-j| \le s$.
- Each dog (including dog 1$1$) may receive the ball at most once.
- Whenever a dog receives the ball, it must either pass it to another dog or finish the game by scoring a goal.
While the dogs were playing, Chef also created a game for developers. He defined the result of a game of soccer for dogs as the sequence of dogs which received the ball in the order in which they received it. The last dog in the sequence is the dog that decided to score a goal; if a dog never received the ball, it does not appear in the sequence. In the game for developers, you should find the number of possible results of soccer for dogs.
Find this number of possible results modulo 109+7$10^9 + 7$. Two results of soccer for dogs (sequences of dogs' numbers) are considered different if these sequences have different lengths or if there is a valid index i$i$ such that the i$i$-th dog in one sequence is different from the i$i$-th dog in the other sequence.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains a single integer N$N$.
- The second line contains N$N$ space-separated integers A1,A2,…,AN$A_1, A_2, \ldots, A_N$ denoting the skill levels of the dogs.

-----Output-----
For each test case, print a single line containing one integer - the number of different results of soccer for dogs, modulo 109+7$10^9 + 7$.

-----Constraints-----
- 1≤T≤10$1 \le T \le 10$
- 1≤N≤105$1 \le N \le 10^5$
- 1≤Ai≤2$1 \le A_i \le 2$ for each valid i$i$

-----Subtasks-----
Subtask #1 (10 points): N≤10$N \le 10$
Subtask #2 (30 points): N≤103$N \le 10^3$
Subtask #3 (60 points): original constraints

-----Example Input-----
3
4
1 1 1 1
3
2 2 2
4
1 2 1 1

-----Example Output-----
4
5
6

-----Explanation-----
Example case 1: The following results are possible: 1$1$, [1,2]$[1, 2]$, [1,2,3]$[1, 2, 3]$, [1,2,3,4]$[1, 2, 3, 4]$.
Example case 2: The following results are possible: [1]$[1]$, [1,2]$[1, 2]$, [1,2,3]$[1, 2, 3]$, [1,3,2]$[1, 3, 2]$, [1,3]$[1, 3]$.

```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 array1(size):\r\n    return [0 for _ in range(size)]\r\n\r\n\r\ndef array2(rows, cols):\r\n    return [[0 for _ in range(cols)] for _ in range(rows)]\r\n\r\n\r\nt = int(input())\r\nfor _ in range(t):\r\n    n = int(input())\r\n    a = list(map(int, input().split()))\r\n    no_of_twos = array1(n + 1)\r\n    for i in range(n - 1, -1, -1):\r\n        if a[i] == 1:\r\n            no_of_twos[i] = 0\r\n        else:\r\n            no_of_twos[i] += 1\r\n            no_of_twos[i] += no_of_twos[i + 1]\r\n    dp = array1(n + 1)\r\n    dp[0] = 1\r\n    ans = 1\r\n    for i in range(1, n):\r\n        if i - 1 >= 0:\r\n            dp[i] += dp[i - 1]\r\n        if i - 2 >= 0 and a[i - 2] == 2:\r\n            dp[i] += dp[i - 2]\r\n        if i - 3 >= 0 and a[i - 3] == 2 and a[i - 2] == 2:\r\n            dp[i] += dp[i - 3]\r\n        dp[i] = dp[i] % 1000000007\r\n        ans += dp[i]\r\n        x = no_of_twos[i + 1]\r\n        if i + 1 < n and a[i - 1] == 2:\r\n            ans += (x * dp[i - 1])\r\n            if x % 2 == 0:\r\n                if i + x + 1 < n:\r\n                    ans += dp[i - 1]\r\n                if i + x + 2 < n and a[i + x + 2] == 2:\r\n                    ans += dp[i - 1]\r\n        ans = ans % 1000000007\r\n    print(ans % 1000000007)\r\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14161