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

public class Solution {
  static class Pair {
    int item1, item2;

    Pair(int item1, int item2) {
      set(item1, item2);
    }

    void set(int item1, int item2) {
      this.item1 = item1;
      this.item2 = item2;
    }

    void println() {
      System.out.println((item1 + 1) + " " + (item2 + 1));
    }
  }

  static class Duo {
    Long sum;
    Pair pair;

    Duo(long sum, Pair pair) {
      this.sum = sum;
      this.pair = pair;
    }
  }

  static class DuoComparator implements Comparator<Duo> {
    public int compare(Duo duo1, Duo duo2) {
      return duo1.sum.compareTo(duo2.sum);
    }
  }

  static long sum(long[] array) {
    long s = 0;
    for (int i = 0; i < array.length; ++i) {
      s += array[i];
    }
    return s;
  }

  static long findBestSingleSwap(long aSum, long bSum, Pair swap) {
    long bestSumDiff = Long.MAX_VALUE;
    for (int i = 0; i < a.length; ++i) {
      for (int j = 0; j < b.length; ++j) {
        long newASum = aSum - a[i] + b[j];
        long newBSum = bSum - b[j] + a[i];
        long newSumDiff = Math.abs(newASum - newBSum);
        if (newSumDiff < bestSumDiff) {
          bestSumDiff = newSumDiff;
          swap.set(i, j);
        }
      }
    }
    return bestSumDiff;
  }

  static Duo findClosestDuo(Duo[] duos, long target) {
    int l = 0;
    int r = duos.length - 1;
    long smallestDiff = Long.MAX_VALUE;
    int index = 0;

    while (l <= r) {
      int mid = (l + r) >> 1;
      long diff = Math.abs(duos[mid].sum - target);
      if (diff < smallestDiff) {
        smallestDiff = diff;
        index = mid;
      }
      
      if (duos[mid].sum > target) {
        r = mid - 1;
      } else if (duos[mid].sum < target) {
        l = mid + 1;
      } else {
        break;
      }
    }
    return duos[index];
  }

  static long findBestDoubleSwap(long aSum, long bSum, Pair swap1, Pair swap2) {
    long bestSumDiff = Long.MAX_VALUE;
    if (b.length < 2) {
      return bestSumDiff;
    }

    Duo[] bDuos = new Duo[(b.length - 1 ) * b.length / 2];
    int index = 0;
    for (int i = 0; i < b.length; ++i) {
      for (int j = i + 1; j < b.length; ++j) {
        bDuos[index++] = new Duo((long) -2 * (b[i] + b[j]), new Pair(i, j));
      }
    }
    Arrays.sort(bDuos, new DuoComparator());

    for (int i = 0; i < a.length; ++i) {
      for (int j = i + 1; j < a.length; ++j) {
        long fixed = aSum - bSum - 2 * (a[i] + a[j]);
        Duo closestDuo = findClosestDuo(bDuos, fixed);
        long diff = Math.abs(closestDuo.sum - fixed);
        if (diff < bestSumDiff) {
          bestSumDiff = diff;
          swap1.set(i, closestDuo.pair.item1);
          swap2.set(j, closestDuo.pair.item2);
        }
      }
    }
    return bestSumDiff;
  }

  static long[] a;
  static long[] b;

  public static void main(String[] args) {
    MyScanner sc = new MyScanner();
    int n = sc.nextInt();
    a = new long[n];
    for (int i = 0; i < n; ++i) {
      a[i] = sc.nextInt();
    }
    int m = sc.nextInt();
    b = new long[m];
    for (int i = 0; i < m; ++i) {
      b[i] = sc.nextInt();
    }

    long aSum = sum(a);
    long bSum = sum(b);
    long sumDiff = Math.abs(aSum - bSum);

    Pair singleSwap = new Pair(-1, -1);
    long bestSingleSwapSumDiff = findBestSingleSwap(aSum, bSum, singleSwap);

    Integer aIndex1 = -1, bIndex1 = -1, aIndex2 = -1, bIndex2 = -1;
    Pair doubleSwap1 = new Pair(-1, -1);
    Pair doubleSwap2 = new Pair(-1, -1);
    long bestDoubleSwapSumDiff = findBestDoubleSwap(aSum, bSum, doubleSwap1, doubleSwap2);

    if (sumDiff <= bestSingleSwapSumDiff && sumDiff <= bestDoubleSwapSumDiff) {
      System.out.println(sumDiff);
      System.out.println(0);
    } else if (bestSingleSwapSumDiff <= bestDoubleSwapSumDiff) {
      System.out.println(bestSingleSwapSumDiff);
      System.out.println(1);
      singleSwap.println();
    } else {
      System.out.println(bestDoubleSwapSumDiff);
      System.out.println(2);
      doubleSwap1.println();
      doubleSwap2.println();
    }
  }

  public static class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    public MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

    long nextLong() {
      return Long.parseLong(next());
    }

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

  }
}