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 int N = 3010;
long long a[N], b[N], n, m;
long long sa = 0, sb = 0, bestSa, bestSb;
pair<int, int> ansOne, ansTwo;
vector<long long> va, vb;
void add(long long *arr, int size, vector<long long> &v) {
  for (int i = 0; i < size; ++i)
    for (int j = i + 1; j < size; ++j) v.push_back(arr[i] + arr[j]);
}
long long one() {
  long long ba = sa;
  long long bb = sb;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      long long nsa = sa - a[i] + b[j], nsb = sb - b[j] + a[i];
      if (llabs(nsa - nsb) < llabs(ba - bb)) {
        ba = nsa;
        bb = nsb;
        ansOne = pair<int, int>(i + 1, j + 1);
      }
    }
  }
  return llabs(ba - bb);
}
long long two() {
  long long diff = llabs(sa - sb);
  for (int i = 0; i < (int)va.size(); ++i) {
    long long x = va[i];
    long long y = x + ((sb - sa) / 2);
    int at = lower_bound(vb.begin(), vb.end(), y) - vb.begin();
    for (int j = at - 1; j <= at; ++j) {
      if (j >= 0 and j < (int)vb.size()) {
        long long nsa = sa - x + vb[j];
        long long nsb = sb - vb[j] + x;
        if (llabs(nsa - nsb) < diff) {
          diff = llabs(nsa - nsb);
          ansTwo = pair<int, int>(x, vb[j]);
        }
      }
    }
  }
  return diff;
}
pair<int, int> find(long long e, long long *arr, int size) {
  for (int i = 0; i < size; ++i)
    for (int j = i + 1; j < size; ++j)
      if (arr[i] + arr[j] == e) return pair<int, int>(i + 1, j + 1);
}
void solve() {
  long long d0 = llabs(sa - sb), d1 = one(), d2 = d1;
  if (n > 1 and m > 1) {
    d2 = two();
  }
  long long best = min(d0, min(d1, d2));
  cout << best << "\n";
  if (best == d0) {
    cout << "0\n";
  } else if (best == d1) {
    cout << "1\n";
    cout << ansOne.first << " " << ansOne.second << "\n";
  } else {
    vector<pair<int, int> > pans;
    pans.push_back(find(ansTwo.first, a, n));
    pans.push_back(find(ansTwo.second, b, m));
    cout << "2\n";
    cout << pans[0].first << " " << pans[1].first << "\n";
    cout << pans[0].second << " " << pans[1].second << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sa += a[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    sb += b[i];
  }
  add(a, n, va);
  add(b, m, vb);
  sort(vb.begin(), vb.end());
  solve();
  return 0;
}