Tom is a boy whose dream is to become a scientist, he invented a lot in his spare time. He came up with a great idea several days ago: to make a stopwatch by himself! So he bought a seven-segment display immediately.
The seven elements of the display are all light-emitting diodes (LEDs) and can be lit in different combinations to represent the arabic numerals like:
However, just when he finished the programs and tried to test the stopwatch, some of the LEDs turned out to be broken! Some of the segments can never be lit while others worked fine. So the display kept on producing some ambiguous states all the time...
Tom has recorded a continuous sequence of states which were produced by the display and is curious about whether it is possible to understand what this display was doing. He thinks the first step is to determine the state which the display will show *next*, could you help him?
Please note that the display works well despite those broken segments, which means that the display will keep on counting down *cyclically* starting from a certain number (can be any one of 0-9 since we don't know where this record starts from). 'Cyclically' here means that each time when the display reaches 0, it will keep on counting down starting from 9 again.
For convenience, we refer the seven segments of the display by the letters A to G as the picture below:
For example, if the record of states is like:
It's not that hard to figure out that ONLY segment B is broken and the sequence of states the display is trying to produce is simply "_9 -> 8 -> 7 -> 6 -> 5_". Then the next number should be 4, but considering of the brokenness of segment B, the next state should be:
The first line of the input gives the number of test cases, t (1 ≤ t ≤ 2000). Each test case is a line containing an integer n (1 ≤ n ≤ 100) which is the number of states Tom recorded and a list of the n states separated by spaces. Each state is encoded into a 7-character string represent the display of segment A-G, from the left to the right. Characters in the string can either be '_1_' or '_0_', denoting the corresponding segment is on or off, respectively.
For each test case, if the input unambiguously determines the next state of the display print the next state (in the same format as the input). Otherwise, you should print "_ERROR!_" (without quotes).
## Input
The first line of the input gives the number of test cases, t (1 ≤ t ≤ 2000). Each test case is a line containing an integer n (1 ≤ n ≤ 100) which is the number of states Tom recorded and a list of the n states separated by spaces. Each state is encoded into a 7-character string represent the display of segment A-G, from the left to the right. Characters in the string can either be '_1_' or '_0_', denoting the corresponding segment is on or off, respectively.
## Output
For each test case, if the input unambiguously determines the next state of the display print the next state (in the same format as the input). Otherwise, you should print "_ERROR!_" (without quotes).
[samples]
**Definitions**
Let $ t \in \mathbb{Z} $ be the number of test cases.
For each test case $ k \in \{1, \dots, t\} $:
- Let $ n_k \in \mathbb{Z} $ be the number of recorded states.
- Let $ S_k = (s_{k,1}, s_{k,2}, \dots, s_{k,n_k}) $ be the sequence of recorded states, where each $ s_{k,i} \in \{0,1\}^7 $ represents the on/off state of segments $ A $ to $ G $ in order.
Let $ D: \{0,1,2,3,4,5,6,7,8,9\} \to \{0,1\}^7 $ be the canonical mapping from digits to segment patterns (fixed, known encoding).
Let $ B \subseteq \{A,B,C,D,E,F,G\} $ be the set of *permanently broken* segments (unknown a priori), such that for all observed states $ s_{k,i} $, the actual digit $ d_i $ displayed satisfies:
$$
\forall j \in \{1,\dots,7\}, \quad s_{k,i}[j] =
\begin{cases}
D(d_i)[j] & \text{if segment } j \text{ is not broken} \\
0 & \text{if segment } j \text{ is broken}
\end{cases}
$$
**Constraints**
1. $ 1 \le t \le 2000 $
2. $ 1 \le n_k \le 100 $ for each test case
3. Each state string is exactly 7 characters long, composed of '0' or '1'
4. The display counts *down cyclically*: if current digit is $ d $, next is $ d-1 \mod 10 $
5. The sequence of recorded states corresponds to a contiguous subsequence of such a cyclic countdown, starting from some unknown digit
**Objective**
For each test case:
- Determine the set $ \mathcal{D} $ of all possible digit sequences $ (d_1, \dots, d_{n_k}) \in \{0,\dots,9\}^{n_k} $ such that:
- $ d_{i} \equiv d_{i+1} + 1 \pmod{10} $ for all $ i \in \{1, \dots, n_k-1\} $
- $ \exists B \subseteq \{A,\dots,G\} $ such that $ s_{k,i} = \text{mask}(D(d_i), B) $, where $ \text{mask}(x, B) $ turns off all segments in $ B $
- If $ \mathcal{D} $ contains exactly one possible next digit $ d_{n_k+1} = (d_{n_k} - 1) \mod 10 $, output the corresponding masked pattern $ \text{mask}(D(d_{n_k+1}), B) $
- Otherwise, output "ERROR!"