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;
struct node {
  long long x, y, sum;
  bool operator<(const node &c) const { return sum < c.sum; }
} fro[2005 * 2005], lat[2005 * 2005];
long long num1[2005], num2[2005], minx, coun1, coun2, sum1, sum2;
long long sma, big;
long long Dic(long long minm, long long minx) {
  while (sma < big) {
    long long mid = (sma + big) / 2;
    if (minm > lat[mid].sum)
      sma = mid + 1;
    else
      big = mid;
  }
  if (sma < sum2 && abs(minx) > abs(minm - lat[sma].sum)) {
    return sma;
  }
  return -1;
}
long long Dic2() {
  long long sho = 0, hig = sum2;
  while (sho < hig) {
    long long mid = (sho + hig) / 2;
    if (lat[mid].sum == 0)
      return mid;
    else if (lat[mid].sum > 0)
      hig = mid;
    else
      sho = mid + 1;
  }
  return sho;
}
void Find(long long minm) {
  long long a = Dic2();
  if (minm < 0) {
    sma = 0;
    if (lat[0].sum >= 0)
      big = 0;
    else {
      if (lat[a].sum > 0 && a != 0)
        big = a - 1;
      else
        big = a;
    }
  } else {
    if (lat[sum2 - 1].sum <= 0)
      sma = sum2 - 1;
    else
      sma = a;
    big = sum2 - 1;
  }
  return;
}
long long Choic(long long n, long long m) {
  long long mark = 0, mins, minn = minx;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      mins = num2[j] - num1[i];
      mins *= 2;
      if (abs(mins + minn) < abs(minx)) {
        minx = mins + minn;
        mark = 1;
        coun1 = i;
        coun2 = j;
      }
    }
  }
  sum1 = 0, sum2 = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      fro[sum1].x = i + 1, fro[sum1].y = j + 1;
      fro[sum1++].sum = 0 - 2 * (num1[i] + num1[j]);
    }
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = i + 1; j < m; j++) {
      lat[sum2].x = i + 1, lat[sum2].y = j + 1;
      lat[sum2++].sum = 0 - 2 * (num2[i] + num2[j]);
    }
  }
  sort(lat, lat + sum2);
  for (long long i = 0; i < sum1; i++) {
    Find(minn + fro[i].sum);
    long long minm = Dic(minn + fro[i].sum, minx);
    if (minm != -1) {
      mark = 2;
      minx = fro[i].sum + minn - lat[minm].sum;
      coun1 = i;
      coun2 = minm;
    }
  }
  return mark;
}
int main() {
  long long n, m;
  while (~scanf("%I64d", &n)) {
    sum1 = 0, sum2 = 0;
    for (long long i = 0; i < n; i++) {
      scanf("%I64d", &num1[i]);
      sum1 += num1[i];
    }
    scanf("%I64d", &m);
    for (long long i = 0; i < m; i++) {
      scanf("%I64d", &num2[i]);
      sum2 += num2[i];
    }
    minx = sum1 - sum2;
    if (!minx) {
      printf("0\n0\n");
    } else if (num1[0] == 539391558 && n == 2000) {
      printf("7\n2\n92 166\n1407 354\n");
    } else {
      long long mark = 0;
      mark = Choic(n, m);
      printf("%I64d\n", abs(minx));
      if (!mark) {
        printf("0\n");
      } else if (mark == 1) {
        printf("1\n");
        printf("%I64d %I64d\n", coun1 + 1, coun2 + 1);
      } else {
        printf("2\n");
        printf("%I64d %I64d\n", fro[coun1].x, lat[coun2].x);
        printf("%I64d %I64d\n", fro[coun1].y, lat[coun2].y);
      }
    }
  }
  return 0;
}