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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
struct Data {
  long long v;
  int x, y;
  Data() {}
  Data(long long tv, int tx, int ty) {
    v = tv;
    x = tx;
    y = ty;
  }
};
int a[2010], b[2010];
Data mp1[4000010], mp2[4000010];
long long gabs(long long x) { return x < 0 ? -x : x; }
bool operator<(Data a, Data b) { return a.v < b.v; }
int main() {
  int n;
  scanf("%d", &n);
  long long sa = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sa += a[i];
  }
  int m;
  scanf("%d", &m);
  long long sb = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    sb += b[i];
  }
  long long t0 = gabs(sa - sb);
  long long t1 = oo;
  int tx, ty;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (gabs(sa - sb - 2ll * (a[i] - b[j])) < t1) {
        t1 = gabs(sa - sb - 2ll * (a[i] - b[j]));
        tx = i;
        ty = j;
      }
  if (n == 1 || m == 1) {
    if (t0 <= t1)
      printf("%lld\n0\n", t0);
    else
      printf("%lld\n1\n%d %d\n", t1, tx, ty);
    return 0;
  }
  long long t2 = oo;
  int tx1, ty1, tx2, ty2;
  int tot;
  for (int i = 1; i < m; i++)
    for (int j = i + 1; j <= m; j++) {
      mp1[++tot] = Data(2ll * (b[i] + b[j]), i, j);
      mp2[tot] = Data(-2ll * (b[i] + b[j]), i, j);
    }
  sort(mp1 + 1, mp1 + tot + 1);
  sort(mp2 + 1, mp2 + tot + 1);
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      Data tmp1 =
          *lower_bound(mp1 + 1, mp1 + tot + 1,
                       Data(-(sa - sb - 2ll * a[i] - 2ll * a[j]), 0, 0));
      int pl1 = lower_bound(mp1 + 1, mp1 + tot + 1,
                            Data(-(sa - sb - 2ll * a[i] - 2ll * a[j]), 0, 0)) -
                mp1;
      Data tmp2 = *lower_bound(mp2 + 1, mp2 + tot + 1,
                               Data(sa - sb - 2ll * a[i] - 2ll * a[j], 0, 0));
      int pl2 = lower_bound(mp2 + 1, mp2 + tot + 1,
                            Data(sa - sb - 2ll * a[i] - 2ll * a[j], 0, 0)) -
                mp2;
      tmp2.v = -tmp2.v;
      Data tmp;
      if (pl1 <= tot && gabs(sa - sb - 2ll * a[i] - 2ll * a[j] + tmp1.v) < t2) {
        t2 = gabs(sa - sb - 2ll * a[i] - 2ll * a[j] + tmp1.v);
        tx1 = i;
        tx2 = j;
        ty1 = tmp1.x;
        ty2 = tmp1.y;
      }
      if (pl2 <= tot && gabs(sa - sb - 2ll * a[i] - 2ll * a[j] + tmp2.v) < t2) {
        t2 = gabs(sa - sb - 2ll * a[i] - 2ll * a[j] + tmp2.v);
        tx1 = i;
        tx2 = j;
        ty1 = tmp2.x;
        ty2 = tmp2.y;
      }
    }
  if (t0 <= t1 && t0 <= t2)
    printf("%lld\n0\n", t0);
  else if (t1 <= t2)
    printf("%lld\n1\n%d %d\n", t1, tx, ty);
  else
    printf("%lld\n2\n%d %d\n%d %d\n", t2, tx1, ty1, tx2, ty2);
  return 0;
}