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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        InputReader inputReader = new InputReader(in);
        PrintWriter out = new PrintWriter(System.out);

        int N = inputReader.getNextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = inputReader.getNextInt();
        }
        int M = inputReader.getNextInt();
        int[] b = new int[M];
        for(int i = 0; i < M; i++) {
            b[i] = inputReader.getNextInt();
        }

        /*int[] a = new int[2000];
        int[] b = new int[2000];
        Random random = new Random();
        for(int i = 0; i < a.length; i++) {
            a[i] = random.nextInt();
        }
        for(int i = 0; i < b.length; i++) {
            b[i] = random.nextInt();
        }*/

        Solution solution = getSolutionWithOneMove(a, b);

        //long currentTime = System.currentTimeMillis();
        getSolutionWithTwoMoves(a, b, solution);
        //out.println("Start - End: " + (System.currentTimeMillis() - currentTime));

        out.println(solution.diff);
        out.println(solution.k);
        for(int i = 0; i < solution.k; i++) {
            out.println(solution.moves[i].x + " " + solution.moves[i].y);
        }

        in.close();
        out.close();
    }

    public static Solution getSolutionWithOneMove(int[] a, int[] b) {
        long sumA = 0;
        long sumB = 0;
        long[] elementsOfA = new long[a.length];
        long[] elementsOfB = new long[b.length];
        Map<Long, Integer> positionsOfA = new HashMap<>();
        Map<Long, Integer> positionsOfB = new HashMap<>();
        for(int i = 0; i < a.length; i++) {
            sumA = sumA + a[i];
            elementsOfA[i] = a[i];
            positionsOfA.put(elementsOfA[i], i+1);
        }
        for(int i = 0; i < b.length; i++) {
            sumB = sumB + b[i];
            elementsOfB[i] = b[i];
            positionsOfB.put(elementsOfB[i], i+1);
        }

        Arrays.sort(elementsOfA);
        Arrays.sort(elementsOfB);

        int i = 0;
        int j = 0;
        Solution sol = new Solution();
        sol.diff = Math.abs(sumA - sumB);
        sol.k = 0;
        while(i < elementsOfA.length && j < elementsOfB.length) {
            if(Math.abs(sumA + 2 * elementsOfB[j] - sumB - 2 * elementsOfA[i]) < sol.diff) {
                sol.diff = Math.abs(sumA + 2 * elementsOfB[j] - sumB - 2 * elementsOfA[i]);
                sol.k = 1;
                sol.moves[0].x = positionsOfA.get(elementsOfA[i]);
                sol.moves[0].y = positionsOfB.get(elementsOfB[j]);
            }
            if(sumA < sumB) {
                if(sumA - elementsOfA[i] + elementsOfB[j] < sumB - elementsOfB[j] + elementsOfA[i]) {
                    j++;
                } else {
                    i++;
                }
            } else {
                if(sumA - elementsOfA[i] + elementsOfB[j] > sumB - elementsOfB[j] + elementsOfA[i]) {
                    i++;
                } else {
                    j++;
                }
            }
        }
        return sol;
    }

    public static void getSolutionWithTwoMoves(int[] a, int[] b, Solution sol) {
        long sumA = 0;
        long sumB = 0;
        Pair[] elementsOfA = new Pair[a.length * (a.length-1) / 2];
        Pair[] elementsOfB = new Pair[b.length * (b.length-1) / 2];

        //long currentTime = System.currentTimeMillis();
        int cnt = 0;
        for(int i = 0; i < a.length; i++) {
            sumA = sumA + a[i];
            for(int j = i + 1; j < a.length; j++) {
                elementsOfA[cnt] = new Pair(a[i] + a[j], 5000 * (i + 1) + j + 1);
                ++cnt;
            }
        }
        cnt = 0;
        for(int i = 0; i < b.length; i++) {
            sumB = sumB + b[i];
            for(int j = i + 1; j < b.length; j++) {
                elementsOfB[cnt] = new Pair(b[i] + b[j], 5000 * (i + 1) + j + 1);
                ++cnt;
            }
        }
        //System.out.println("Processing: " + (System.currentTimeMillis() - currentTime));

        Arrays.sort(elementsOfA, (p1, p2) -> Integer.compare(p1.x, p2.x));
        Arrays.sort(elementsOfB, (p1, p2) -> Integer.compare(p1.x, p2.x));

        int i = 0;
        int j = 0;
        while(i < elementsOfA.length && j < elementsOfB.length) {
            long newSumA = sumA - elementsOfA[i].x + elementsOfB[j].x;
            long newSumB = sumB - elementsOfB[j].x + elementsOfA[i].x;
            if(Math.abs(newSumA - newSumB) < sol.diff) {
                sol.diff = Math.abs(newSumA - newSumB);
                sol.k = 2;
                int pairA = elementsOfA[i].y;
                int pairB = elementsOfB[j].y;
                sol.moves[0].x = pairA / 5000;
                sol.moves[0].y = pairB / 5000;
                sol.moves[1].x = pairA % 5000;
                sol.moves[1].y = pairB % 5000;
            }
            if(sumA < sumB) {
                if(newSumA < newSumB) {
                    j++;
                } else {
                    i++;
                }
            } else {
                if(newSumA > newSumB) {
                    i++;
                } else {
                    j++;
                }
            }
        }
    }

    public static class Solution {
        long diff;
        int k;
        Pair[] moves = new Pair[2];

        Solution() {
            this.moves[0] = new Pair(0, 0);
            this.moves[1] = new Pair(0, 0);

        }
    }

    public static class Pair {
        int x;
        int y;

        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void shuffle(long[] arr) {
        Random random = new Random();
        for(int i = arr.length; i > 1; i--) {
            int j = random.nextInt(i);
            long aux = arr[i-1];
            arr[i-1] = arr[j];
            arr[j] = aux;
        }
    }

    public static class InputReader {

        static final String SEPARATOR = " ";

        String[] split;
        int head = 0;
        BufferedReader in;

        public InputReader(BufferedReader in) {
            this.in = in;
        }

        private void fillBuffer() throws IOException {
            if(split == null || head >= split.length) {
                head = 0;
                split = in.readLine().split(SEPARATOR);
            }
        }

        public String getNextToken() throws IOException {
            fillBuffer();
            return split[head++];

        }

        public int getNextInt() throws IOException {
            return Integer.parseInt(getNextToken());
        }
    }

}