Problem: Professor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a sa as close as possible to the sum of the elements in the array b sb. So he wants to minimize the value v = |sa - sb|.

In one operation professor can swap some element from the array a and some element from the array b. For example if the array a is [5, 1, 3, 2, 4] and the array b is [3, 3, 2] professor can swap the element 5 from the array a and the element 2 from the array b and get the new array a [2, 1, 3, 2, 4] and the new array b [3, 3, 5].

Professor doesn't want to make more than two swaps. Find the minimal value v and some sequence of no more than two swaps that will lead to the such value v. Professor makes swaps one by one, each new swap he makes with the new arrays a and b.

Input

The first line contains integer n (1 ≤ n ≤ 2000) — the number of elements in the array a.

The second line contains n integers ai ( - 109 ≤ ai ≤ 109) — the elements of the array a.

The third line contains integer m (1 ≤ m ≤ 2000) — the number of elements in the array b.

The fourth line contains m integers bj ( - 109 ≤ bj ≤ 109) — the elements of the array b.

Output

In the first line print the minimal value v = |sa - sb| that can be got with no more than two swaps.

The second line should contain the number of swaps k (0 ≤ k ≤ 2).

Each of the next k lines should contain two integers xp, yp (1 ≤ xp ≤ n, 1 ≤ yp ≤ m) — the index of the element in the array a and the index of the element in the array b in the p-th swap.

If there are several optimal solutions print any of them. Print the swaps in order the professor did them.

Examples

Input

5
5 4 3 2 1
4
1 1 1 1


Output

1
2
1 1
4 2


Input

5
1 2 3 4 5
1
15


Output

0
0


Input

5
1 2 3 4 5
4
1 2 3 4


Output

1
1
3 1

Solution (in JAVA):

Solution:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class D {

    static class Sums implements Comparable<Sums>{
        int index1;
        int index2;
        long sum;

        public Sums(int index1, int index2, long sum){
            this.index1 = index1;
            this.index2 = index2;
            this.sum = sum;
        }

        public long getSum(){
            return this.sum;
        }

        public int getIndex1(){
            return this.index1;
        }

        public int getIndex2(){
            return this.index2;
        }

        @Override
        public int compareTo(Sums o) {
            return Long.compare(this.sum,o.getSum());
        }
    }

    public static void main(String[] args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] array = in.readLine().split(" ");
        int[] aArray = new int[n];
        long sumA = 0, sumB = 0;
        for(int i = 0; i < n; i++){
            aArray[i] = Integer.parseInt(array[i]);
            sumA += (long) aArray[i];
        }

        int m = Integer.parseInt(in.readLine());
        int[] bArray = new int[m];
        array = in.readLine().split(" ");

        for(int i = 0; i < m; i++){
            bArray[i] = Integer.parseInt(array[i]);
            sumB += bArray[i];
        }

        long best = Math.abs(sumA - sumB);

        long difference = 0;

        long numberOfSwaps = 0;

        int index1=-1,index2=-1,index3=-1,index4=-1;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                difference = Math.abs((sumA - aArray[i] + bArray[j]) - (sumB - bArray[j] + aArray[i]));

                if(difference < best){
                    best = difference;
                    index1 = i + 1;
                    index2 = j + 1;
                    numberOfSwaps = 1;
                }
            }
        }

        if(n == 1 || m == 1){
            System.out.println(best);
            System.out.println(numberOfSwaps);
            if(numberOfSwaps == 1){
                System.out.println(index1 + " " + index2);
            }
            return;
        }


        Sums[] sumsA = new Sums[n*(n-1)/2];
        Sums[] sumsB = new Sums[m*(m-1)/2];
        int index = 0;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                sumsA[index] = new Sums(i,j,(long) aArray[i] + aArray[j]);
                index++;
            }
        }

        Arrays.sort(sumsA);
        index = 0;

        for(int i = 0; i < m; i++){
            for(int j = i + 1; j < m; j++){
                sumsB[index] = new Sums(i,j,(long) bArray[i] + bArray[j]);
                index++;
            }
        }

        Arrays.sort(sumsB);


        index = 0;

        for(int i = 0; i < sumsA.length; i++){
            while(true){
                long sum1 = sumA - sumsA[i].getSum() + sumsB[index].getSum();
                long sum2 = sumB - sumsB[index].getSum() + sumsA[i].getSum();
                if(index + 1 == sumsB.length || sum2 <= sum1){
                    break;
                }else{
                    index++;
                }
            }

            difference = Math.abs((sumA - sumsA[i].getSum() + sumsB[index].getSum())
                    - (sumB - sumsB[index].getSum() + sumsA[i].getSum()));

            if(difference<best){
                best = difference;
                numberOfSwaps = 2;
                index1 = sumsA[i].getIndex1() + 1;
                index3 = sumsA[i].getIndex2() + 1;
                index2 = sumsB[index].getIndex1() + 1;
                index4 = sumsB[index].getIndex2() + 1;
            }
        }

        System.out.println(best);
        System.out.println(numberOfSwaps);
        if(numberOfSwaps == 1){
            System.out.println(index1 + " " + index2);
        }else if(numberOfSwaps == 2){
            System.out.println(index1 + " " + index2);
            System.out.println(index3 + " " + index4);
        }

    }
}