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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Artem Gilmudinov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.readInt();
            }
            int m = in.readInt();
            int[] b = new int[m];
            for (int i = 0; i < m; i++) {
                b[i] = in.readInt();
            }
            long min = Long.MAX_VALUE;
            long sum1, sum2;
            sum1 = 0;
            sum2 = 0;
            for (int i = 0; i < n; i++) {
                sum1 += a[i];
            }
            for (int j = 0; j < m; j++) {
                sum2 += b[j];
            }
            int[] bb = new int[m];
            System.arraycopy(b, 0, bb, 0, m);
            Arrays.sort(bb);
            min = Math.min(Math.abs(sum1 - sum2), min);
            int left, right, mid1, mid2;
            ArrayList<Integer> indexes = new ArrayList<>();
            long val = 0;
            for (int i = 0; i < n; i++) {
                left = 0;
                right = m - 1;
                mid1 = mid2 = 0;
                while (right - left >= 3) {
                    mid1 = left + (right - left) / 3;
                    mid2 = right - (right - left) / 3;
                    if (f(sum1, sum2, a[i], bb[mid1]) > f(sum1, sum2, a[i], bb[mid2])) {
                        left = mid1;
                    } else {
                        right = mid2;
                    }
                }
                for (int j = left; j <= right; j++) {
                    val = f(sum1, sum2, a[i], bb[j]);
                    if (min > val) {
                        min = val;
                        indexes.clear();
                        indexes.add(i);
                    }
                }
            }
            int size = m * (m - 1) / 2;
            long[] pairs = new long[size];

            for (int i = 0, z = 0; i < m; i++) {
                for (int j = i + 1; j < m; j++, z++) {
                    pairs[z] = b[i] + b[j];
                }
            }
            Arrays.sort(pairs);
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    left = 0;
                    right = size - 1;
                    mid1 = mid2 = 0;
                    while (right - left >= 3) {
                        mid1 = left + (right - left) / 3;
                        mid2 = right - (right - left) / 3;
                        if (f(sum1, sum2, a[i] + a[j], pairs[mid1]) > f(sum1, sum2, a[i] + a[j], pairs[mid2])) {
                            left = mid1;
                        } else {
                            right = mid2;
                        }
                    }
                    for (int z = left; z <= right; z++) {
                        val = f(sum1, sum2, a[i] + a[j], pairs[z]);
                        if (min > val) {
                            min = val;
                            indexes.clear();
                            indexes.add(i);
                            indexes.add(j);
                        }
                    }
                }
            }
            out.println(min);
            out.println(indexes.size());
            if (indexes.size() == 1) {
                for (int i = 0; i < m; i++) {
                    if (f(sum1, sum2, a[indexes.get(0)], b[i]) == min) {
                        out.println((indexes.get(0) + 1) + " " + (i + 1));
                        return;
                    }
                }
            }
            if (indexes.size() == 2) {
                for (int i = 0; i < m; i++) {
                    for (int j = i + 1; j < m; j++) {
                        if (f(sum1, sum2, a[indexes.get(0)] + a[indexes.get(1)], b[i] + b[j]) == min) {
                            out.println((indexes.get(0) + 1) + " " + (i + 1));
                            out.println((indexes.get(1) + 1) + " " + (j + 1));
                            return;
                        }
                    }
                }
            }

        }

        public long f(long sum1, long sum2, long f, long s) {
            return Math.abs(sum1 - 2 * f - sum2 + 2 * s);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}