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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
int inline in() {
  int x = 0, c;
  for (; (unsigned)((c = getchar()) - '0') >= 10;) {
    if (c == '-') return -in();
    if (!~c) throw ~0;
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while ((unsigned)((c = getchar()) - '0') < 10);
  return x;
}
int n, m;
const int Maxn = 2005;
int a[Maxn], b[Maxn];
long long sa, sb;
long long V = 1e17;
pair<int, int> ans1 = make_pair(-1, -1);
pair<int, int> ans2 = make_pair(-1, -1);
pair<long long, pair<int, int> > aa[Maxn * Maxn], bb[Maxn * Maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sa += (long long)a[i];
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    sb += (long long)b[i];
  }
  chkmin(V, llabs(sa - sb));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (V > llabs(sa - sb - 2 * ((long long)a[i] - b[j]))) {
        V = llabs(sa - sb - 2 * ((long long)a[i] - b[j]));
        ans1 = make_pair(i, j);
      }
    }
  }
  if (n == 1 || m == 1) {
    if (ans1 == make_pair(-1, -1)) {
      printf("%lld\n", V);
      printf("0\n");
      return 0;
    }
    printf("%lld\n", V);
    printf("1\n");
    printf("%d %d\n", ans1.first, ans1.second);
    return 0;
  }
  int na = 0, nb = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j) {
        aa[na++] = make_pair(((long long)a[i] + a[j]) * 2, make_pair(i, j));
      }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++)
      if (i != j) {
        bb[nb++] = make_pair(((long long)b[i] + b[j]) * 2, make_pair(i, j));
      }
  sort(bb, bb + nb);
  for (int i = 0; i < (na); i++) {
    auto it = aa[i];
    auto it2 = upper_bound(bb, bb + nb,
                           make_pair(it.first - sa + sb, make_pair(0, 0)));
    int p = it2 - bb;
    if (p < nb) {
      if (V > llabs(sa - sb - it.first + it2->first)) {
        V = llabs(sa - sb - it.first + it2->first);
        ans1 = make_pair(it.second.first, it2->second.first);
        ans2 = make_pair(it.second.second, it2->second.second);
      }
    }
    if (p != 0) {
      it2--;
      if (V > llabs(sa - sb - it.first + it2->first)) {
        V = llabs(sa - sb - it.first + it2->first);
        ans1 = make_pair(it.second.first, it2->second.first);
        ans2 = make_pair(it.second.second, it2->second.second);
      }
    }
  }
  if (ans1 == make_pair(-1, -1)) {
    printf("%lld\n", V);
    printf("0\n");
    return 0;
  }
  if (ans2 == make_pair(-1, -1)) {
    printf("%lld\n", V);
    printf("1\n");
    printf("%d %d\n", ans1.first, ans1.second);
    return 0;
  }
  printf("%lld\n", V);
  printf("2\n");
  printf("%d %d\n", ans1.first, ans1.second);
  printf("%d %d\n", ans2.first, ans2.second);
  return 0;
}