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.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

import static java.lang.Math.abs;

/**
 * Created by name_no on 31.01.16.
 *
 */
public class C620D {
    public static void main(String[] args) throws IOException {

        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int na = Integer.valueOf(r.readLine());
        long[] a = Arrays.stream(r.readLine().split(" ")).parallel().mapToLong(Long::valueOf).toArray();

        int nb = Integer.valueOf(r.readLine());
        long[] b = Arrays.stream(r.readLine().split(" ")).parallel().mapToLong(Long::valueOf).toArray();


        long sa = Arrays.stream(a).parallel().sum();
        long sb = Arrays.stream(b).parallel().sum();

        long diff = sa-sb;
        long diffAbs = abs(diff);

//        System.out.println("starting, diff is "+diff);
        class Result {
            long ultimateDiff;
            List<int[]> moves;

            public Result(long ultimateDiff, int[]... moves) {
                this.ultimateDiff = ultimateDiff;
                this.moves = Arrays.asList(moves);
            }

            @Override
            public String toString() {
                StringBuilder b = new StringBuilder();
                b.append(String.format("%d\n%d\n",
                        ultimateDiff, moves.size()));
                for (int[] move : moves)
                    b.append(String.format("%d %d\n", move[0]+1, move[1]+1));
                return b.toString();
            }
        }

        Result best = new Result(diffAbs);
        for (int i=0; i < na; i++) {
            for (int j = 0; j < nb; j++) {
                long cost = (a[i]-b[j]) * 2L;
                long ultimateDiff = abs(diff-cost);

                if (ultimateDiff<diffAbs && (ultimateDiff < best.ultimateDiff )) {
                    best = new Result(ultimateDiff, new int[]{i, j});

                    if (ultimateDiff == 0) {
                        System.out.print(best);
                        System.exit(0);
                    }
                }
            }
        }

        List<Duplet> bSums = new ArrayList<>();
        for (int i=0; i<nb; i++) {
            for (int j=i+1; j<nb; j++) {
                bSums.add(new Duplet(b[i]+b[j], i, j));
            }
        }

        if (!bSums.isEmpty()) {
            bSums.sort(Comparator.comparingLong(Duplet::getSum));

            for (int i = 0; i < na; i++) {
                for (int j = i + 1; j < na; j++) {
                    long aSum = a[i] + a[j];
                    Duplet db = nearest(bSums, diff, aSum);
                    long signedDiff = diff - (aSum - db.sum) * 2L;
                    long ultimateDiff = abs(signedDiff);

                    if (ultimateDiff < best.ultimateDiff) {
                        best = new Result(ultimateDiff, new int[]{i, db.i}, new int[]{j, db.j});
                    }
                }
            }
        }
        System.out.print(best);
    }

    static class Duplet {
        long sum;
        int i;
        int j;

        public Duplet(long sum, int i, int j) {
            this.sum = sum;
            this.i = i;
            this.j = j;
        }

        public long getSum() {
            return this.sum;
        }
    }

    private static Duplet nearest(List<Duplet> list, long diff, long aSum) {

        int lowerBound = 0;
        int upperBound = list.size() - 1;

//         0 1 2 3 4 5 6 7 8 9
//         1 2 3 4 5 6 7 8 9 10
        long bestDiff = abs(diff);
        int bestIndex = upperBound;

//        diff -aSum*2 +min*2 = best
//        best - diff + aSUm*2 = min*2
//        best = -abs(best);
//        long min = best - diff + aSum*2;
        while (true) {
            int i = (lowerBound+upperBound)/2;
            Duplet db = list.get(i);
            long signedDiff = diff - aSum * 2L + db.sum * 2L;

//            System.out.println("bestDiff "+bestDiff+" currDiff "+signedDiff+" lower: "+lowerBound+" upper: "+upperBound+" i: "+i);

            if (abs(signedDiff) < bestDiff) {
                bestDiff = abs(signedDiff);
                bestIndex = i;
            }
            if (signedDiff==0) {
                break;
            }

            if (lowerBound >= upperBound)
                break;

            if (signedDiff > 0) {
                upperBound = i-1;
            } else {
                lowerBound = i+1;
            }
        }

        return list.get(bestIndex);
    }
}