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;
long long t, n, m, u, v, q, r, ql, qr, k, l, s, x, y, w, h, c, d;
const int N = 4e6 + 500;
const int LN = 23;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 62LL;
const bool JUDGE = false;
pair<long long, pair<int, int> > a[N], b[N];
long long fx[N], fy[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (JUDGE) {
    freopen("angry.in", "r", stdin);
    freopen("angry.out", "w", stdout);
  }
  cin >> n;
  long long sa = 0, sb = 0;
  for (int i = 0; i < n; ++i) {
    cin >> fx[i];
    sa += fx[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> fy[i];
    sb += fy[i];
  }
  long long ans = abs(sb - sa);
  int swaps = 0;
  long long pos[2][2];
  memset(pos, -1, sizeof(pos));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      sa += (-fx[i] + fy[j]);
      sb += (fx[i] - fy[j]);
      if (ans > abs(sb - sa)) {
        ans = abs(sb - sa);
        swaps = 1;
        pos[0][0] = i;
        pos[0][1] = j;
      }
      sa -= (-fx[i] + fy[j]);
      sb -= (fx[i] - fy[j]);
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      a[i * n + j] = make_pair(fx[i] + fx[j], make_pair(i, j));
      if (i == j) a[i * n + j].first = -INF;
    }
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) {
      b[i * m + j] = make_pair(fy[i] + fy[j], make_pair(i, j));
      if (i == j) b[i * m + j].first = -INF;
    }
  bool swapped = false;
  if (sa > sb) {
    swapped = true;
    swap(a, b);
    swap(m, n);
    swap(sa, sb);
  }
  sort(b, b + m * m);
  for (int i = 0; i < n * n; ++i) {
    if (a[i].first == -INF) continue;
    int p = upper_bound(b, b + m * m,
                        make_pair(a[i].first + (sb - sa) / 2LL,
                                  make_pair(INT_MAX, INT_MAX))) -
            b;
    if (p != m * m && b[p].first != -INF) {
      sa -= (a[i].first - b[p].first);
      sb -= (b[p].first - a[i].first);
      if (abs(sb - sa) < ans) {
        swaps = 2;
        ans = abs(sb - sa);
        pos[0][0] = a[i].second.first;
        pos[1][0] = a[i].second.second;
        pos[0][1] = b[p].second.first;
        pos[1][1] = b[p].second.second;
      }
      sa += (a[i].first - b[p].first);
      sb += (b[p].first - a[i].first);
    }
    if (p != 0) p--;
    if (b[p].first == -INF) continue;
    sa -= (a[i].first - b[p].first);
    sb -= (b[p].first - a[i].first);
    if (abs(sb - sa) < ans) {
      ans = abs(sb - sa);
      swaps = 2;
      pos[0][0] = a[i].second.first;
      pos[1][0] = a[i].second.second;
      pos[0][1] = b[p].second.first;
      pos[1][1] = b[p].second.second;
    }
    sa += (a[i].first - b[p].first);
    sb += (b[p].first - a[i].first);
  }
  if (swapped && swaps == 2) {
    swap(pos[0][1], pos[0][0]);
    swap(pos[1][0], pos[1][1]);
  }
  cout << ans << '\n';
  cout << swaps << '\n';
  for (int i = 0; i < swaps; ++i) {
    for (int j = 0; j < 2; ++j) cout << pos[i][j] + 1 << " ";
    cout << '\n';
  }
  return 0;
}