Hide

Problem E
Orthogonal Rotation

Accepted submissions to this problem will be granted a score of 15
Languages en is

You are given two vectors v1,v2 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 v2, meaning that we can take the last value in v2 and put it at the front.

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

Note that to check whether v1,v2 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 1n2105, 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 k0 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
Hide

Please log in to submit a solution to this problem

Log in