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.util.*;

public class D implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new D().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private void solve() {
        int n = readInt();
        int[] a = readIntArray(n);
        int m = readInt();
        int[] b = readIntArray(m);

        int bestK = 0;
        long bestDif = 0;

        long bestSumA = 0, bestSumB = 0;

        long sumA = 0, sumB = 0;
        for (int i = 0; i < n; i++) {
            sumA += a[i];
        }
        for (int i = 0; i < m; i++) {
            sumB += b[i];
        }
        bestDif = Math.abs(sumA - sumB);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (bestDif > Math.abs((sumA - a[i] + b[j]) - (sumB - b[j] + a[i]))) {
                    bestK = 1;
                    bestDif = Math.abs((sumA - a[i] + b[j]) - (sumB - b[j] + a[i]));
                    bestSumA = a[i];
                    bestSumB = b[j];
                }
            }
        }

        Set<Long> setDifA = new HashSet<>();
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                setDifA.add(2L * (a[i] + a[j]));
            }
        }
        long[] difA = new long[setDifA.size()];
        int count = 0;
        for (long dif : setDifA) {
            difA[count++] = dif;
        }
        Arrays.sort(difA);

        if (difA.length > 0) {
            for (int i = 0; i < m; i++) {
                for (int j = i + 1; j < m; j++) {
                    long difB = b[i] + b[j];
                    long neededValue = sumA - sumB + 2 * difB;

                    int bestIndex = -1;
                    int left = 0, right = difA.length - 1;
                    while (left <= right) {
                        int mid = (left + right) >> 1;
                        if (difA[mid] >= neededValue) {
                            bestIndex = mid;
                            right = mid - 1;
                        } else {
                            left = mid + 1;
                        }
                    }
                    if (bestIndex == -1) {
                        bestIndex = difA.length - 1;
                    }

                    if (bestDif > Math.abs((sumA + difB - difA[bestIndex] / 2) - (sumB + difA[bestIndex] / 2 - difB))) {
                        bestDif = Math.abs((sumA + difB - difA[bestIndex] / 2) - (sumB + difA[bestIndex] / 2 - difB));
                        bestK = 2;
                        bestSumA = difA[bestIndex] / 2;
                        bestSumB = difB;
                    }

                    if (bestIndex > 0) {
                        bestIndex--;
                        if (bestDif > Math.abs((sumA + difB - difA[bestIndex] / 2) - (sumB + difA[bestIndex] / 2 - difB))) {
                            bestDif = Math.abs((sumA + difB - difA[bestIndex] / 2) - (sumB + difA[bestIndex] / 2 - difB));
                            bestK = 2;
                            bestSumA = difA[bestIndex] / 2;
                            bestSumB = difB;
                        }
                        bestIndex++;
                    }

                    if (bestIndex + 1 < difA.length) {
                        bestIndex++;
                        if (bestDif > Math.abs((sumA + difB - difA[bestIndex] / 2) - (sumB + difA[bestIndex] / 2 - difB))) {
                            bestDif = Math.abs((sumA + difB - difA[bestIndex] / 2) - (sumB + difA[bestIndex] / 2 - difB));
                            bestK = 2;
                            bestSumA = difA[bestIndex] / 2;
                            bestSumB = difB;
                        }
                        bestIndex++;
                    }
                }
            }
        }

        out.println(bestDif);
        out.println(bestK);
        if (bestK == 1) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (a[i] == bestSumA && b[j] == bestSumB) {
                        out.println((i + 1) + " " + (j + 1));
                        return;
                    }
                }
            }
        }
        if (bestK == 2) {
            int i1 = 0, i2 = 0, j1 = 0, j2 = 0;
            for (int i = 0; i < n && i1 == 0; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (a[i] + a[j] == bestSumA) {
                        i1 = i + 1;
                        i2 = j + 1;
                        break;
                    }
                }
            }
            for (int i = 0; i < m && j1 == 0; i++) {
                for (int j = i + 1; j < m; j++) {
                    if (b[i] + b[j] == bestSumB) {
                        j1 = i + 1;
                        j2 = j + 1;
                        break;
                    }
                }
            }
            out.println(i1 + " " + j1);
            out.println(i2 + " " + j2);
        }
    }
}