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 int MAXN = 2005;
int n, m;
int a[MAXN], b[MAXN], lenb;
long long ans, SA, SB;
int c[3][2], tot;
struct node {
  long long val;
  int ID1, ID2;
  bool operator<(const node &px) const { return val < px.val; }
} B[MAXN * MAXN];
int Read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x * 10) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
void Put1(long long x) {
  if (x > 9) Put1(x / 10);
  putchar(x % 10 ^ 48);
}
void Put(long long x, char c = -1) {
  if (x < 0) putchar('-'), x = -x;
  Put1(x);
  if (c >= 0) putchar(c);
}
template <typename T>
T Max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
int Get(long long x, int a1, int a2) {
  int l = 1, r = lenb, ret = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (SA + B[mid].val - a[a1] - a[a2] < SB - B[mid].val + a[a1] + a[a2])
      l = mid + 1, ret = mid;
    else
      r = mid - 1;
  }
  return ret;
}
void update(int x, int a1, int a2) {
  long long dz =
      Abs(SA + B[x].val - a[a1] - a[a2] - (SB - B[x].val + a[a1] + a[a2]));
  if (dz < ans) {
    ans = dz;
    tot = 2;
    c[1][0] = a1;
    c[1][1] = B[x].ID1;
    c[2][0] = a2;
    c[2][1] = B[x].ID2;
  }
}
int main() {
  n = Read();
  for (int i = 1; i <= n; ++i) SA += a[i] = Read();
  m = Read();
  for (int i = 1; i <= m; ++i) SB += b[i] = Read();
  ans = Abs(SA - SB);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      long long dz = Abs(SA + b[j] - a[i] - (SB - b[j] + a[i]));
      if (dz < ans) {
        ans = dz;
        tot = 1;
        c[1][0] = i;
        c[1][1] = j;
      }
    }
  for (int i = 1; i <= m; ++i)
    for (int j = i + 1; j <= m; ++j)
      B[++lenb].val = b[i] + b[j], B[lenb].ID1 = i, B[lenb].ID2 = j;
  sort(B + 1, B + lenb + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) {
      int fu = Get(a[i] + a[j], i, j);
      if (fu) update(fu, i, j);
      if (fu < lenb) update(fu + 1, i, j);
    }
  Put(ans, '\n');
  Put(tot, '\n');
  for (int i = 1; i <= tot; ++i) Put(c[i][0], ' '), Put(c[i][1], '\n');
  return 0;
}