#P7779. The Oculus

The Oculus

The Oculus

Problem Description

Let's define the Fibonacci sequence F1,F2,F_1,F_2,\dots as F1=1,F2=2,Fi=Fi1+Fi2F_1=1,F_2=2,F_i=F_{i-1}+F_{i-2} (i3i\geq 3). It's well known that every positive integer xx has its unique Fibonacci representation (b1,b2,,bn)(b_1,b_2,\dots,b_n) such that: · b1×F1+b2×F2++bn×Fn=xb_1\times F_1+b_2\times F_2+\dots+b_n\times F_n=x. · bn=1b_n=1, and for each ii (1i<n1\leq i<n), bi{0,1}b_i\in\{0,1\} always holds. · For each ii (1i<n1\leq i<n), bi×bi+1=0b_i\times b_{i+1}=0 always holds. For example, 4=(1,0,1)4=(1,0,1), 5=(0,0,0,1)5=(0,0,0,1), and 20=(0,1,0,1,0,1)20=(0,1,0,1,0,1) because 20=F2+F4+F6=2+5+1320=F_2+F_4+F_6=2+5+13. There are two positive integers AA and BB written in Fibonacci representation, Skywalkert calculated the product of AA and BB and written the result CC in Fibonacci representation. Assume the Fibonacci representation of CC is (b1,b2,,bn)(b_1,b_2,\dots,b_n), Little Q then selected a bit kk (1k<n1\leq k<n) such that bk=1b_k=1 and modified bkb_k to 00. It is so slow for Skywalkert to calculate the correct result again using Fast Fourier Transform and tedious reduction. Please help Skywalkert to find which bit kk was modified.

Input

The first line of the input contains a single integer TT (1T100001 \leq T \leq 10\,000), the number of test cases. For each case, the first line of the input contains the Fibonacci representation of AA, the second line contains the Fibonacci representation of BB, and the third line contains the Fibonacci representation of modified CC. Each line starts with an integer nn, denoting the length of the Fibonacci representation, followed by nn integers b1,b2,,bnb_1,b_2,\dots,b_n, denoting the value of each bit. It is guaranteed that: · 1A,B10000001\leq |A|,|B|\leq 1\,000\,000. · 2CA+B+12\leq |C|\leq |A|+|B|+1. ·A,B5000000\sum |A|,\sum |B|\leq 5\,000\,000.

Output

For each test case, output a single line containing an integer, the value of kk.

Sample Input

1
3 1 0 1
4 0 0 0 1
6 0 1 0 0 0 1

Sample Output

4

Source

2020 Multi-University Training Contest 2