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;
int gcd(int f, int s) {
  if (s == 0)
    return f;
  else
    return gcd(s, f % s);
}
int const N = 1000006;
long long const M = 1020;
long double const ep = .000000000000000001;
long long arr[N], arr1[N];
int main() {
  int n, m;
  scanf("%d", &n);
  long long sum = 0, sum1 = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", arr + i);
    sum += arr[i];
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%lld", arr1 + i);
    sum1 += arr1[i];
  }
  if (sum == sum1) {
    printf("0\n0");
    return 0;
  }
  long long best = abs(sum - sum1);
  int ind = -1, ind1 = -1;
  for (int i = 0; i < n; i++) {
    long long temp = sum, temp1 = sum1;
    for (int x = 0; x < m; x++) {
      temp -= arr[i];
      temp += arr1[x];
      temp1 -= arr1[x];
      temp1 += arr[i];
      if (abs(temp - temp1) < best) {
        ind = i + 1, ind1 = x + 1;
        best = abs(temp - temp1);
      }
      temp = sum, temp1 = sum1;
    }
  }
  int indd = -1, indd1 = -1, indd2 = -1, indd21 = -1;
  vector<pair<long long, pair<int, int> > > v, v1;
  for (int i = 0; i < n; i++)
    for (int x = i + 1; x < n; x++)
      v.push_back(make_pair(arr[i] + arr[x], make_pair(i, x)));
  for (int i = 0; i < m; i++)
    for (int x = i + 1; x < m; x++)
      v1.push_back(make_pair(arr1[i] + arr1[x], make_pair(i, x)));
  sort(v1.begin(), v1.end());
  long long want = (sum - sum1) / 2;
  long long test = 1e17;
  long long num = -1;
  for (int i = 0; i < v.size(); i++) {
    int left = 0, right = v1.size() - 1, mid;
    while (left <= right) {
      mid = (left + right) / 2;
      long long curr = v[i].first - v1[mid].first;
      if (test > abs(curr - want)) {
        test = abs(curr - want);
        num = curr;
        indd = v[i].second.first + 1, indd1 = v[i].second.second + 1;
        indd2 = v1[mid].second.first + 1, indd21 = v1[mid].second.second + 1;
      }
      if (curr > want)
        left = mid + 1;
      else
        right = mid - 1;
    }
  }
  long long s = sum, s1 = sum1;
  s -= num;
  s1 += num;
  if (ind == -1 && indd == -1) {
    printf("%lld\n0", best);
    return 0;
  }
  if (best > abs(s - s1)) {
    printf("%lld\n", abs(s - s1));
    printf("2\n%d %d\n%d %d", indd, indd2, indd1, indd21);
  } else {
    printf("%lld\n", best);
    printf("1\n%d %d", ind, ind1);
  }
  return 0;
}