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;
inline long long input() {
  long long n;
  cin >> n;
  return n;
}
long long pw(long long a, long long b) {
  return (!b ? 1 : (b & 1 ? a * pw(a * a, b / 2) : pw(a * a, b / 2)));
}
long long sum1, sum2;
vector<long long> num1;
vector<long long> num2;
bool comp(long long def, long long i) {
  if (abs(def) > abs(i)) return 1;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n;
  long long s = 0;
  long long r1, r2;
  long long o1, o2;
  long long inp1[n];
  for (int i = 0; i < n; i++) {
    cin >> inp1[i];
    sum1 += inp1[i];
  }
  cin >> m;
  long long inp2[m];
  for (int i = 0; i < m; i++) {
    cin >> inp2[i];
    sum2 += inp2[i];
  }
  long long dif = sum1 - sum2;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (comp(dif, (sum1 - inp1[i] + inp2[j]) - (sum2 + inp1[i] - inp2[j]))) {
        s = 1;
        dif = (sum1 - inp1[i] + inp2[j]) - (sum2 + inp1[i] - inp2[j]);
        r1 = i;
        r2 = j;
      }
    }
  }
  if (m == 1 || n == 1) {
    cout << abs(dif) << "\n";
    if (s == 0) {
      cout << 0;
    }
    if (s == 1) {
      cout << 1 << "\n";
      cout << r1 + 1 << " " << r2 + 1;
    }
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      num1.push_back(inp1[i] + inp1[j]);
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (j == i) continue;
      num2.push_back(inp2[i] + inp2[j]);
    }
  }
  sort(num2.begin(), num2.end());
  for (int i = 0; i < num1.size(); i++) {
    long long f = sum1 - sum2 - (2 * num1[i]);
    long long po;
    long long k = -f;
    int l = 0, r = num2.size();
    bool works = true;
    while (r - l > 1) {
      int mid = (r + l) / 2;
      if (num2[mid] * 2 == k) {
        l = mid;
        break;
      }
      if (num2[mid] * 2 > k) {
        int mid2 = (mid + l) / 2;
        if (num2[mid2] * 2 < k && abs(mid2 - mid) <= 2) {
          if (abs(k - num2[mid2] * 2) > abs(num2[mid] * 2 - k)) {
            works = false;
            po = num2[mid];
            break;
          } else {
            works = false;
            po = num2[mid2];
            break;
          }
        } else
          r = mid;
      } else {
        int mid2 = (mid + r) / 2;
        if (num2[mid2] * 2 > k && abs(mid2 - mid) <= 2) {
          if (abs(k - num2[mid] * 2) > abs(num2[mid2] * 2 - k)) {
            works = false;
            po = num2[mid2];
            break;
          } else {
            works = false;
            po = num2[mid];
            break;
          }
        } else
          l = mid;
      }
    }
    if (works) {
      if (comp(dif, f + 2 * num2[l])) {
        dif = f + 2 * num2[l];
        s = 2;
        o1 = num1[i];
        o2 = num2[l];
      }
    } else {
      if (comp(dif, f + 2 * po)) {
        dif = f + 2 * po;
        s = 2;
        o1 = num1[i];
        o2 = po;
      }
    }
  }
  cout << abs(dif) << "\n";
  if (s == 0) {
    cout << 0;
  }
  if (s == 1) {
    cout << 1 << "\n";
    cout << r1 + 1 << " " << r2 + 1;
  }
  if (s == 2) {
    cout << 2 << "\n";
    int an1, an2, an3, an4;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j == i) continue;
        if (o1 == inp1[i] + inp1[j]) {
          an1 = i;
          an3 = j;
          break;
        }
      }
    }
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < m; j++) {
        if (j == i) continue;
        if (o2 == inp2[i] + inp2[j]) {
          an2 = i;
          an4 = j;
          break;
        }
      }
    }
    cout << an1 + 1 << ' ' << an2 + 1 << "\n"
         << an3 + 1 << ' ' << an4 + 1 << "\n";
  }
  return 0;
}