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 _620D {

    static Random rand = new Random();

    static int[] pairs;
    static int n, m;
    static long[] a, b;

    static boolean lessThan(int i, int j) {
        return b[i % m] - a[i / m] < b[j % m] - a[j / m];
    }

    static void sort(int l, int r) {
        int i = l, j = r, x = pairs[rand.nextInt(r - l + 1) + l];
        do {
            while (lessThan(pairs[i], x)) i++;
            while (lessThan(x, pairs[j])) j--;
            if (i <= j) {
                int tmp = pairs[i];
                pairs[i] = pairs[j];
                pairs[j] = tmp;
                i++;
                j--;
            }
        } while (i <= j);
        if (i < r) sort(i, r);
        if (j > l) sort(l, j);
    }

    public static void main(String[] args) throws Exception {
        Reader.init(System.in);
        BufferedWriter cout = new BufferedWriter(new OutputStreamWriter(System.out));

        n = Reader.nextInt();
        long sa = 0, sb = 0;

        a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Reader.nextInt();
            sa += a[i];
        }

        m = Reader.nextInt();
        b = new long[m];
        for (int i = 0; i < m; i++) {
            b[i] = Reader.nextInt();
            sb += b[i];
        }

        long ans = Math.abs(sa - sb);
        int[][] sol = new int[2][2];
        int solSize = 0;

        // try to swap one pair
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++) {
                long newSa = sa + b[j] - a[i];
                long newSb = sb + a[i] - b[j];
                long newAns = Math.abs(newSa - newSb);
                if (newAns < ans) {
                    ans = newAns;
                    solSize = 1;
                    sol[0][0] = i;
                    sol[0][1] = j;
                }
            }

        // try to swap two pairs
        pairs = new int[n * m];
        for (int i = 0; i < n * m; i++) pairs[i] = i;
        sort(0, pairs.length - 1);

//        Arrays.sort(pairs, (i, j) -> Long.compare(b[i % m] - a[i / m], b[j % m] - a[j / m]));

        for (int i = 0, j = n * m - 1; i < j; ) {
            long tmp = 2 * (b[pairs[i] % m] - a[pairs[i] / m] + b[pairs[j] % m] - a[pairs[j] / m]);
            long newAns = Math.abs(sa - sb + tmp);
            if (newAns < ans && pairs[i] % m != pairs[j] % m && pairs[i] / m != pairs[j] / m) {
                ans = newAns;
                solSize = 2;
                sol[0][0] = pairs[i] / m;
                sol[0][1] = pairs[i] % m;
                sol[1][0] = pairs[j] / m;
                sol[1][1] = pairs[j] % m;
            }

            if (sa - sb + tmp == 0) {
                i++;
                j--;
            } else if (sa - sb + tmp < 0) {
                i++;
            } else {
                j--;
            }
        }

        System.out.println(ans);
        System.out.println(solSize);
        for (int i = 0; i < solSize; i++) System.out.printf("%d %d%n", sol[i][0] + 1, sol[i][1] + 1);

        cout.close();
    }

    static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
        final U _1;
        final V _2;

        private Pair(U key, V val) {
            this._1 = key;
            this._2 = val;
        }

        public static <U extends Comparable<U>, V extends Comparable<V>> Pair<U, V> instanceOf(U _1, V _2) {
            return new Pair<U, V>(_1, _2);
        }

        @Override
        public String toString() {
            return _1 + " " + _2;
        }

        @Override
        public int hashCode() {
            int res = 17;
            res = res * 31 + _1.hashCode();
            res = res * 31 + _2.hashCode();
            return res;
        }

        @Override
        public int compareTo(Pair<U, V> that) {
            int res = this._1.compareTo(that._1);
            if (res < 0 || res > 0) return res;
            else return this._2.compareTo(that._2);
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) return true;
            if (!(obj instanceof Pair)) return false;
            Pair<?, ?> that = (Pair<?, ?>) obj;
            return _1.equals(that._1) && _2.equals(that._2);
        }
    }

    /**
     * Class for buffered reading int and double values
     */
    static class Reader {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        /**
         * call this method to initialize reader for InputStream
         */
        static void init(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        /**
         * get next word
         */
        static String next() throws IOException {
            while (!tokenizer.hasMoreTokens()) {
                // TODO add check for eof if necessary
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

        static int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        static double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }

    static class ArrayUtil {
        static void swap(int[] a, int i, int j) {
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(long[] a, int i, int j) {
            long tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(double[] a, int i, int j) {
            double tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(char[] a, int i, int j) {
            char tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(boolean[] a, int i, int j) {
            boolean tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void reverse(int[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(long[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(double[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(char[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(boolean[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static long sum(int[] a) {
            int sum = 0;
            for (int i : a)
                sum += i;
            return sum;
        }

        static long sum(long[] a) {
            long sum = 0;
            for (long i : a)
                sum += i;
            return sum;
        }

        static double sum(double[] a) {
            double sum = 0;
            for (double i : a)
                sum += i;
            return sum;
        }

        static int max(int[] a) {
            int max = Integer.MIN_VALUE;
            for (int i : a)
                if (i > max) max = i;
            return max;
        }

        static int min(int[] a) {
            int min = Integer.MAX_VALUE;
            for (int i : a)
                if (i < min) min = i;
            return min;
        }

        static long max(long[] a) {
            long max = Long.MIN_VALUE;
            for (long i : a)
                if (i > max) max = i;
            return max;
        }

        static long min(long[] a) {
            long min = Long.MAX_VALUE;
            for (long i : a)
                if (i < min) min = i;
            return min;
        }
    }
}