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.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//     Test.testing();
        ConsoleIO io = new ConsoleIO();
        new Main(io).solve();
        io.flush();
    }
    ConsoleIO io;
    Main(ConsoleIO io) {
        this.io = io;
    }

    ArrayList<ArrayList<Edge>> gr1;
    boolean[] visit;
    //

    class Edge {
        public Edge(int c, int u,int v) {
            this.u = u;
            this.v = v;
            this.c = c;
        }
        public int u;
        public int v;
        public int c;
    }

    long mod = 1_000_000_007;
    int n,m,fn;

    public void solve() {
        n = io.readInt();
        int[] a = io.readIntArray();
        m = io.readInt();
        int[] b = io.readIntArray();
        long sumA = 0;
        long sumB = 0;
        for (int i = 0; i < n; i++)
            sumA += a[i];
        for (int i = 0; i < m; i++)
            sumB += b[i];
        long res = Math.abs(sumA - sumB);
        int t = 0;
        int swapA1 = 0, swapB1 = 0, swapA2 = 0, swapB2 = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) {
                long ai = a[i], bj = b[j];
                long x = Math.abs(sumA - ai + bj - (sumB - bj + ai));
                if (x < res) {
                    res = x;
                    t = 1;
                    swapA1 = i + 1;
                    swapB1 = j + 1;
                }
            }

        Edge[] pA = new Edge[n * (n - 1) / 2];
        Edge[] pB = new Edge[m * (m - 1) / 2];

        int k = 0;
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++)
                pA[k++] = new Edge(a[i] + a[j], i, j);
        k = 0;
        for (int i = 0; i < m; i++)
            for (int j = i + 1; j < m; j++)
                pB[k++] = new Edge(b[i] + b[j], i, j);

        Arrays.sort(pA, (e1, e2) -> Integer.compare(e1.c, e2.c));
        Arrays.sort(pB, (e1, e2) -> Integer.compare(e1.c, e2.c));

        if (pA.length > 0 && pB.length > 0) {
            int i = 0, j = 0;
            for (; i < pA.length || j < pB.length; ) {
                Edge ca = i < pA.length ? pA[i] : pA[i - 1];
                Edge cb = j < pB.length ? pB[j] : pB[j - 1];
                long x = sumA - ca.c + cb.c - (sumB - cb.c + ca.c);
                if (Math.abs(x) < res) {
                    t = 2;
                    swapA1 = ca.u + 1;
                    swapA2 = ca.v + 1;
                    swapB1 = cb.u + 1;
                    swapB2 = cb.v + 1;
                    res = Math.abs(x);
                }
                if (i == pA.length)
                    j++;
                else if (j == pB.length)
                    i++;
                else if (x < 0) j++;
                else i++;
            }
        }

        io.writeLine(res + "");
        io.writeLine(t + "");
        if (t == 0) {
            return;
        }
        if (t == 1) {
            io.writeLine(swapA1 + " " + swapB1);
            return;
        }
        io.writeLine(swapA1 + " " + swapB1);
        io.writeLine(swapA2 + " " + swapB2);
    }

    long gcd(long a, long b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a % b);
    }


}

class ConsoleIO {
    BufferedReader br;
    PrintWriter out;
    public ConsoleIO(){br = new BufferedReader(new InputStreamReader(System.in));out = new PrintWriter(System.out);}
    public void flush(){this.out.close();}
    public void writeLine(String s) {this.out.println(s);}
    public void writeInt(int a) {this.out.print(a);this.out.print(' ');}
    public void writeWord(String s){
        this.out.print(s);
    }
    public String readLine() {try {return br.readLine();}catch (Exception ex){ return "";}}
    public long readLong() {
        return Long.parseLong(this.readLine());
    }
    public int readInt() {
        return Integer.parseInt(this.readLine().trim());
    }
    public long[] readLongArray() {
        String[]n=this.readLine().trim().split(" ");long[]r=new long[n.length];
        for(int i=0;i<n.length;i++)r[i]=Long.parseLong(n[i]);
        return r;
    }
    public int[] readIntArray() {
        String[]n=this.readLine().trim().split("\\s+");int[]r=new int[n.length];
        for(int i=0;i<n.length;i++)r[i]=Integer.parseInt(n[i]);
        return r;
    }
    public void writeIntArray(int[] a) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < a.length; i++) {if (i > 0) sb.append(' ');sb.append(a[i]);}
        this.writeLine(sb.toString());
    }
}