Hide

Problem E
Orthogonal Rotation

Languages en is

You are given two vectors $v_1, v_2$ of the same length $n$. You need to make them fit together, which means that they have to be orthogonal to one another. Possibly they fit together from the start, but if not we can amend this. We can rotate $v_2$, meaning that we can take the last value in $v_2$ and put it at the front.

We can do this again and again to get new versions of $v_2$, until we have done it $n$ times and are back where we started.

Note that to check whether $v_1, v_2$ are orthogonal we take the dot product of the vectors. If this dot product is zero they are orthogonal. The dot product is the sum of the product of the first values, the product of the second values and so on.

For what number of rotations do the vectors fit together?

Input

The first line of input contains an integer $1 \leq n \leq 2 \cdot 10^5$, the number of coordinates the vectors have. The next two lines give the two vectors. Each vector is given as a series of space separated integers. Each value is from $-100$ to $100$.

Output

Print all numbers of rotations that make the vectors fit together, that is to say if moving the last value to the front $k$ times makes them fit together you should print $k$ (possibly among other values). We are only considering values of $k \geq 0$ which are less than the length of the vectors. Print the values in ascending order, one number per line. If there are no such values, print $-1$ instead.

Sample Input 1 Sample Output 1
4
1 0 -1 0
0 -1 0 1
0
2
Sample Input 2 Sample Output 2
5
1 2 3 4 5
-3 -2 -1 -5 -4
-1
Sample Input 3 Sample Output 3
3
0 0 0
0 0 0
0
1
2

Please log in to submit a solution to this problem

Log in