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 mod = 998244353;
long long powerMod(long long a, long long n) {
  if (n == 0) return 1;
  long long res = powerMod((a % mod * a % mod) % mod, n / 2) % mod;
  if (n % 2) return (a % mod * res % mod) % mod;
  return res;
}
long long cs[2222], cd[2222];
vector<pair<long long, pair<long long, long long> > > as, bs;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, sum1 = 0, sum2 = 0;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i < n + 1; i++) cin >> a[i], sum1 += a[i];
  long long m;
  cin >> m;
  long long b[m + 1];
  for (long long i = 1; i < m + 1; i++) cin >> b[i], sum2 += b[i];
  if (sum1 == sum2) {
    cout << "0\n0";
    return 0;
  }
  long long mini = LLONG_MAX;
  pair<long long, long long> single, doubl[2];
  long long flag = 1;
  for (long long i = 1; i < n + 1; i++) {
    long long temp1 = sum1 - a[i];
    for (long long j = 1; j < m + 1; j++) {
      long long temp2 = sum2 - b[j];
      if (abs((temp1 + b[j]) - (temp2 + a[i])) < mini) {
        flag = 1;
        mini = abs((temp1 + b[j]) - (temp2 + a[i]));
        single.first = i;
        single.second = j;
      }
    }
  }
  if (n > 1 && m > 1) {
    for (long long i = 1; i < n + 1; i++)
      for (long long j = i + 1; j < n + 1; j++)
        as.push_back({a[i] + a[j], {i, j}});
    for (long long i = 1; i < m + 1; i++)
      for (long long j = i + 1; j < m + 1; j++)
        bs.push_back({b[i] + b[j], {i, j}});
    sort(bs.begin(), bs.end());
    for (long long i = 0; i < (long long)as.size(); i++) {
      long long temp1 = sum1 - as[i].first;
      long long temp2 = sum2 + as[i].first;
      long long l = 0, r = (long long)bs.size() - 1;
      while (l <= r) {
        long long mid = l + (r - l) / 2;
        long long add = bs[mid].first;
        long long first = (temp1 + add);
        long long second = (temp2 - add);
        long long check = abs((temp1 + add) - (temp2 - add));
        if (check < mini) {
          mini = check;
          flag = 2;
          doubl[0] = {as[i].second.first, bs[mid].second.first};
          doubl[1] = {as[i].second.second, bs[mid].second.second};
        }
        if (mini + 1 < bs.size()) {
          long long add = bs[mid + 1].first;
          long long first = (temp1 + add);
          long long second = (temp2 - add);
          long long check = abs((temp1 + add) - (temp2 - add));
          if (check < mini) {
            mini = check;
            flag = 2;
            doubl[0] = {as[i].second.first, bs[mid + 1].second.first};
            doubl[1] = {as[i].second.second, bs[mid + 1].second.second};
          }
        }
        if (mid - 1 >= 0) {
          long long add = bs[mid - 1].first;
          long long first = (temp1 + add);
          long long second = (temp2 - add);
          long long check = abs((temp1 + add) - (temp2 - add));
          if (check < mini) {
            mini = check;
            flag = 2;
            doubl[0] = {as[i].second.first, bs[mid - 1].second.first};
            doubl[1] = {as[i].second.second, bs[mid - 1].second.second};
          }
        }
        if (first > second)
          r = mid - 1;
        else
          l = mid + 1;
      }
    }
  }
  cout << mini << '\n';
  if (flag == 1) {
    cout << flag << '\n';
    cout << single.first << ' ' << single.second << '\n';
  } else {
    cout << flag << '\n';
    cout << doubl[0].first << ' ' << doubl[0].second << '\n';
    cout << doubl[1].first << ' ' << doubl[1].second << '\n';
  }
  return 0;
}