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 long long inf = 9999999999999999;
const int N = 2005;
const int M = 2000005;
const double eps = 1e-6;
vector<pair<int, int> > ans;
int n, m, cnt;
long long a[N], b[N], sum1, sum2;
struct point {
  long long x;
  int id1, id2;
} s[N * N];
bool cmp(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  if (a.id1 != b.id1) return a.id1 < b.id1;
  return a.id2 < b.id2;
}
int BiSearch(long long goal) {
  int l = 0, r = cnt - 1, mid;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (s[mid].x == goal)
      return mid;
    else if (s[mid].x > goal)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
int main() {
  while (~scanf("%d", &n)) {
    int i, j;
    sum1 = sum2 = 0;
    for (i = 0; i < n; i++) scanf("%lld", &a[i]), sum1 += a[i];
    scanf("%d", &m);
    for (i = 0; i < m; i++) scanf("%lld", &b[i]), sum2 += b[i];
    ans.clear();
    if (sum1 == sum2)
      printf("0\n0\n");
    else {
      long long ret = abs(sum1 - sum2);
      long long t = sum1 - sum2, tmp;
      int l = -1, r = -1;
      for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
          tmp = t + 2 * b[i] - 2 * a[j];
          tmp = abs(tmp);
          if (tmp < ret) {
            l = j + 1, r = i + 1;
            ret = tmp;
          }
        }
      }
      if (l != -1) ans.push_back(make_pair(l, r));
      if (n != 1 && m != 1) {
        cnt = 0;
        for (i = 0; i < n; i++)
          for (j = i + 1; j < n; j++) {
            s[cnt].x = a[i] + a[j];
            s[cnt].x *= 2;
            s[cnt].id1 = i + 1, s[cnt++].id2 = j + 1;
          }
        sort(s, s + cnt, cmp);
        long long l1 = -1, r1 = -1;
        long long l2, r2;
        long long t1, t2;
        for (i = 0; i < m; i++) {
          for (j = i + 1; j < m; j++) {
            tmp = t + 2 * (b[i] + b[j]);
            int cur = BiSearch(tmp);
            t1 = abs(tmp - s[cur].x);
            if (cur != 0) t2 = abs(tmp - s[cur - 1].x);
            if (ret <= min(t1, t2)) continue;
            if (cur == 0 || t1 <= t2) {
              ret = t1;
              l1 = s[cur].id1, r1 = i + 1;
              l2 = s[cur].id2, r2 = j + 1;
            }
            if (cur != 0 && t1 > t2) {
              ret = t2;
              l1 = s[cur - 1].id1, r1 = i + 1;
              l2 = s[cur - 1].id2, r2 = j + 1;
            }
          }
        }
        if (l1 != -1) {
          ans.clear();
          ans.push_back(make_pair(l1, r1));
          ans.push_back(make_pair(l2, r2));
        }
      }
      cout << ret << endl;
      cout << ans.size() << endl;
      for (i = 0; i < ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
  return 0;
}