sss

Time limit: 0.5s Memory limit: 256MB Input: Output:

You are given two positive integers n,mn, m and two sequences of positive integers AA and BB. The sequence AA consists of nn elements, each one in the interval [1,m][1, m], while the sequence BB consists of mm elements, each one in the interval [1,n][1, n].

Task

Write a program which finds a nonempty subsequence of AA and a nonempty subsequence of BB, which have equal sums of elements.

Definition: For a sequence C=C0,C1,...,CpC = C_0, C_1, ..., C_p, a subsequence of CC is a sequence of elements Ci1,Ci2,...,CikC_{i_1}, C_{i_2}, ..., C_{i_k} of CC for which 0i1<i2<...<ikp0 ≤ i_1 < i_2 < ... < i_k ≤ p.

Input

From the first line of the standard input, your program reads a positive integer nn - the size of sequence AA. From the second line, your program reads nn positive integers - the elements of AA
From the third line of the standard input, your program reads a positive integer mm - the size of sequence BB. From the fourth line, your program reads mm positive integers - the elements of BB.

Output

On the first line of the standard output, your program should print a positive integer pp - the size of the chosen subsequence of AA. On the second line, your program should print pp integers - the indices of the chosen elements from AA. On the third line of the standard output, your program should print a positive integer qq - the size of the chosen subsequence of BB. On the fourth line, your program should print qq integers - the indices of the chosen elements from BB.

Attention: Indices start from 00. The order in which your program prints the chosen indices doesn't matter. It is guaranteed that at least one solution exists. If more than one solution exists, print any one of them.

Constraints

  • 1n,m1 000 0001 ≤ n, m ≤ 1 \ 000 \ 000

Evaluation

The test cases are divided into groups, each of which consists of two tests. The points for each group are given only if your solution passes both tests from the group.

  • In 10%10\% of the groups n,m20n, m ≤ 20
  • In other 25%25\% оf the groups n,m300n, m ≤ 300

Example

stdin

5        
2 3 3 2 3
3        
4 5 5    

stdout

3    
1 2 4
2    
0 1  

Explanation

a[1]+a[2]+a[4]=3+3+3=9a[1] + a[2] + a[4] = 3 + 3 + 3 = 9

b[0]+b[1]=4+5=9b[0] + b[1] = 4 + 5 = 9.

Another possible solution is: a[2]+a[3]=3+2=5=b[1]a[2] +a[3] = 3 + 2 = 5 = b[1].

Log in or sign up to be able to send submissions!