#P7779. The Oculus
The Oculus
The Oculus
Problem Description
Let's define the Fibonacci sequence as (). It's well known that every positive integer has its unique Fibonacci representation such that: · . · , and for each (), always holds. · For each (), always holds. For example, , , and because . There are two positive integers and written in Fibonacci representation, Skywalkert calculated the product of and and written the result in Fibonacci representation. Assume the Fibonacci representation of is , Little Q then selected a bit () such that and modified to . 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 was modified.
Input
The first line of the input contains a single integer (), the number of test cases. For each case, the first line of the input contains the Fibonacci representation of , the second line contains the Fibonacci representation of , and the third line contains the Fibonacci representation of modified . Each line starts with an integer , denoting the length of the Fibonacci representation, followed by integers , denoting the value of each bit. It is guaranteed that: · . · . ·.
Output
For each test case, output a single line containing an integer, the value of .
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