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.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter pw = new PrintWriter(System.out);
    static int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.solve();
        m.close();
    }

    void close() throws IOException {
        pw.flush();
        pw.close();
        br.close();
    }

    int ri() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    long rl() throws IOException {
        return Long.parseLong(br.readLine());
    }

    int[] ril(int n) throws IOException {
        int[] nums = new int[n];
        int c = 0;
        for (int i = 0; i < n; i++) {
            int sign = 1;
            c = br.read();
            int x = 0;
            if (c == '-') {
                sign = -1;
                c = br.read();
            }
            while (c >= '0' && c <= '9') {
                x = x * 10 + c - '0';
                c = br.read();
            }
            nums[i] = x * sign;
        }
        while (c != '\n' && c != -1) c = br.read();
        return nums;
    }

    long[] rll(int n) throws IOException {
        long[] nums = new long[n];
        int c = 0;
        for (int i = 0; i < n; i++) {
            int sign = 1;
            c = br.read();
            long x = 0;
            if (c == '-') {
                sign = -1;
                c = br.read();
            }
            while (c >= '0' && c <= '9') {
                x = x * 10 + c - '0';
                c = br.read();
            }
            nums[i] = x * sign;
        }
        while (c != '\n' && c != -1) c = br.read();
        return nums;
    }

    char[] rs() throws IOException {
        return br.readLine().toCharArray();
    }

    void solve() throws IOException {
        int n = ri();
        int[] a = ril(n);
        int m = ri();
        int[] b = ril(m);
        long sumA = 0;
        long sumB = 0;
        for (int ai : a) sumA += ai;
        for (int bi : b) sumB += bi;

        long diff = sumA - sumB;

        // no swaps
        long v0 = Math.abs(diff);

        // 1 swap
        long v1 = Long.MAX_VALUE;
        long i1 = -1;
        long j1 = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                long val = Math.abs((sumA - a[i] + b[j]) - (sumB - b[j] + a[i]));
                if (val < v1) {
                    v1 = val;
                    i1 = i;
                    j1 = j;
                }
            }
        }

        // 2 swaps
        List<long[]> pairSumsA = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                pairSumsA.add(new long[]{(long) a[i] + a[j], i, j});
            }
        }
        List<long[]> pairSumsB = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            for (int j = i+1; j < m; j++) {
                pairSumsB.add(new long[]{(long) b[i] + b[j], i, j});
            }
        }
        Collections.sort(pairSumsB, (x1, x2) -> Long.compare(x1[0], x2[0]));
        List<Long> valsOnly = new ArrayList<>(pairSumsB.size());
        for (long[] x : pairSumsB) valsOnly.add(x[0]);

        long v2 = Long.MAX_VALUE;
        long[] v2idx = new long[4];
        for (long[] pair : pairSumsA) {
            long asum = pair[0];
            // choose pair from pairSumsB such that difference is diff / 2
            // in other words, try to find asum - diff/2
            int idx = Collections.binarySearch(valsOnly, asum-diff/2);
            if (idx < 0) idx = -idx-1;
            for (int i = Math.max(idx-1, 0); i <= Math.min(idx+1, pairSumsB.size()-1); i++) {
                long bsum = valsOnly.get(i);
                long val = Math.abs((sumA - asum + bsum) - (sumB - bsum + asum));
                if (val < v2) {
                    v2 = val;
                    v2idx[0] = pair[1];
                    v2idx[1] = pair[2];
                    v2idx[2] = pairSumsB.get(i)[1];
                    v2idx[3] = pairSumsB.get(i)[2];
                }
            }
        }

        if (v0 == Math.min(v0, Math.min(v1, v2))) {
            pw.println(v0);
            pw.println("0");
        } else if (v1 == Math.min(v0, Math.min(v1, v2))) {
            pw.println(v1);
            pw.println("1");
            pw.println((i1+1) + " " + (j1+1));
        } else {
            pw.println(v2);
            pw.println("2");
            pw.println((v2idx[0]+1) + " " + (v2idx[2]+1));
            pw.println((v2idx[1]+1) + " " + (v2idx[3]+1));
        }
    }
}