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>
struct sum {
  long long s, x, y;
} s_a[2000 * 2000], s_b[2000 * 2000];
int cmp(const void *a, const void *b) {
  return (((struct sum *)a)->s > ((struct sum *)b)->s) -
         (((struct sum *)a)->s < ((struct sum *)b)->s);
}
long long search(struct sum *a, long long val, long long n) {
  long long l = 0, r = n * (n - 1) / 2, m;
  while (l + 1 < r) {
    m = (r - l) / 2 + l;
    if (a[m].s * 2 <= val)
      l = m;
    else
      r = m;
  }
  if (l == n * (n - 1) / 2 - 1)
    return l;
  else
    return (llabs(val - a[l].s * 2) < llabs(val - a[l + 1].s * 2)) ? l : l + 1;
}
int main() {
  long long n, m, i, j, k;
  long long a[2000], b[2000];
  long long sum_a = 0, sum_b = 0;
  long long min0, min1, x1, y1, min2, x2, y2;
  scanf("%I64d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    sum_a += a[i];
  }
  scanf("%I64d", &m);
  for (i = 0; i < m; i++) {
    scanf("%I64d", &b[i]);
    sum_b += b[i];
  }
  min0 = min1 = min2 = llabs(sum_a - sum_b);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (llabs(sum_a - sum_b - a[i] * 2 + b[j] * 2) < min1) {
        min1 = llabs(sum_a - sum_b - a[i] * 2 + b[j] * 2);
        x1 = i;
        y1 = j;
      }
  k = 0;
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++) {
      s_a[k].s = a[i] + a[j];
      s_a[k].x = i;
      s_a[k++].y = j;
    }
  k = 0;
  for (i = 0; i < m; i++)
    for (j = i + 1; j < m; j++) {
      s_b[k].s = b[i] + b[j];
      s_b[k].x = i;
      s_b[k++].y = j;
    }
  qsort(s_a, n * (n - 1) / 2, sizeof s_a[0], cmp);
  qsort(s_b, m * (m - 1) / 2, sizeof s_b[0], cmp);
  if (m > 1)
    for (i = 0; i < n * (n - 1) / 2; i++) {
      j = search(s_b, sum_b + s_a[i].s * 2 - sum_a, m);
      if (llabs(sum_a - sum_b - s_a[i].s * 2 + s_b[j].s * 2) < min2) {
        min2 = llabs(sum_a - sum_b - s_a[i].s * 2 + s_b[j].s * 2);
        x2 = i;
        y2 = j;
      }
    }
  if (min0 <= min1 && min0 <= min2)
    printf("%I64d\n0", min0);
  else if (min1 < min0 && min1 <= min2)
    printf("%I64d\n1\n%I64d %I64d", min1, x1 + 1, y1 + 1);
  else if (min2 < min0 && min2 < min1)
    printf("%I64d\n2\n%I64d %I64d\n%I64d %I64d", min2, s_a[x2].x + 1,
           s_b[y2].x + 1, s_a[x2].y + 1, s_b[y2].y + 1);
  return 0;
}