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.*;
import java.util.Map.Entry;

/**
 * Created by viosng on 18.02.2016.
 */
public class TwoArrays {

    private static long minOneSum(long[][] a, long sumA, long[] b, long sumB, List<int[]> steps, long min) {
        TreeMap<Long, Integer> map = new TreeMap<>();
        int aLen = a.length;
        for (int i = 0; i < aLen; i++) {
            map.put(sumA - 2 * a[i][0], (int)a[i][1]);
        }
        int bLen = b.length;
        for (int i = 0; i < bLen; i++) {
            long s = sumB - 2 * b[i];
            Entry<Long, Integer> floor = map.floorEntry(s);
            Entry<Long, Integer> ceil = map.ceilingEntry(s);
            Entry<Long, Integer> m;
            if (floor == null || ceil == null) {
                m = floor == null ? ceil : floor;
            } else {
                m = Math.abs(floor.getKey() - s) < Math.abs(ceil.getKey() - s) ? floor : ceil;
            }
            long mAbs = Math.abs(m.getKey() - s);
            if (mAbs < min) {
                steps.clear();
                steps.add(new int[]{m.getValue(), i});
                min = mAbs;
            }
        }
        return min;
    }

    private static long minTwoSum(long[][] a, long sumA, long[] b, long sumB, List<int[]> steps, long min) {
        int aLen = a.length;
        List<long[]> sortedList = new ArrayList<>();
        //Stopwatch stopwatch = Stopwatch.createStarted();
        for (int i = 0; i < aLen; i++) {
            for (int j = 0; j < i; j++) {
                sortedList.add(new long[]{sumA - 2 * a[i][0] - 2 * a[j][0], a[i][1] * 10000 + a[j][1]});
            }

        }
        long[][] sorted = sortedList.toArray(new long[0][]);
        Comparator<long[]> c = new Comparator<long[]>() {
            @Override
            public int compare(long[] o1, long[] o2) {
                return Long.compare(o1[0], o2[0]);
            }
        };
        Arrays.sort(sorted, c);
        //System.out.println("map two add = " + stopwatch.elapsed(TimeUnit.MILLISECONDS));
        int bLen = b.length;
        long[] sample = new long[2];
        for (int i = 0; i < bLen; i++) {
            for (int j = 0; j < i; j++) {
                long s = sumB - 2 * b[i] - 2 * b[j];
                sample[0] = s;
                int index = Arrays.binarySearch(sorted, sample, c);
                if (index < 0) {
                    index = -index - 1;
                    if (index > 0 && index < sorted.length) {
                        index =  Math.abs(sorted[index][0] - s) < Math.abs(sorted[index - 1][0] - s) ? index : index - 1;
                    } else if (index >= sorted.length) {
                        index--;
                    }
                }
                long mAbs = Math.abs(sorted[index][0] - s);
                if (mAbs < min) {
                    steps.clear();
                    steps.add(new int[]{(int) (sorted[index][1]/ 10000), i});
                    steps.add(new int[]{(int) (sorted[index][1]% 10000), j});
                    min = mAbs;
                }
            }
        }
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            in.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        //System.out.println("stopwatch = " + stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
        return min;
    }

    private static void solve(long[] a, long[] b) {
        int nA = a.length;
        long sumA = 0;
        for (int i = 0; i < nA; i++) {
            sumA += a[i];
        }
        int nB = b.length;
        long sumB = 0;
        for (int i = 0; i < nB; i++) {
            sumB += b[i];
        }
        long[][] aA = new long[a.length][2];
        for (int i = 0; i < a.length; i++) {
            aA[i][0] = a[i];
            aA[i][1] = i;
        }
        Arrays.sort(aA, new Comparator<long[]>() {
            @Override
            public int compare(long[] o1, long[] o2) {
                return Long.compare(o1[0], o2[0]);
            }
        });
        List<int[]> steps = new ArrayList<>();
        long min = minOneSum(aA, sumA, b, sumB, steps, Math.abs(sumA - sumB));
        if (nA > 1 && nB > 1) min = minTwoSum(aA, sumA, b, sumB, steps, min);
        System.out.println(min);
        System.out.println(steps.size());
        for (int[] step : steps) {
            System.out.println((step[0] + 1) + " " + (step[1] + 1));
        }
    }

    private static void solveMain() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        /*int nA = Integer.parseInt(in.readLine());
        long[] a = Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
        int nB = Integer.parseInt(in.readLine());
        long[] b = Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();*/
        int nA = Integer.parseInt(in.readLine());
        String[] split = in.readLine().split(" ");
        long[] a = new long[nA];
        for (int i = 0; i < nA; i++) {
            a[i] = Long.parseLong(split[i]);
        }
        int nB = Integer.parseInt(in.readLine());
        split = in.readLine().split(" ");
        long[] b = new long[nB];
        for (int i = 0; i < nB; i++) {
            b[i] = Long.parseLong(split[i]);
        }
        solve(a, b);
    }

    /*private static void solveTest(int n) {
        Supplier<long[]> getArray = () -> range(0, n).mapToLong(i -> ThreadLocalRandom.current().nextInt()).toArray();
        Stopwatch started = Stopwatch.createStarted();
        solve(getArray.get(), getArray.get());
        System.out.println("started = " + started.stop().elapsed(TimeUnit.MILLISECONDS));
    }*/

    public static void main(String... args) throws IOException {
        //solveTest(2000);
        solveMain();
    }
}