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 = 1e9 + 7;
void print_width(long long x) {
  std::cout << std::fixed;
  std::cout << std::setprecision(x);
}
bool rev(long long x, long long y) { return x > y; }
bool sortinrev(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.first > b.first);
}
long long modulo(long long x, long long N) { return (x % N + N) % N; }
long long max(long long a, long long b) {
  if (a >= b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a <= b)
    return a;
  else
    return b;
}
long long diff(long long a, long long b) {
  if (a >= b)
    return a - b;
  else
    return b - a;
}
void pairsort(long long a[], long long b[], long long n) {
  pair<long long, long long> pairt[n];
  for (long long i = 0; i < n; i++) {
    pairt[i].first = a[i];
    pairt[i].second = b[i];
  }
  sort(pairt, pairt + n);
  for (long long i = 0; i < n; i++) {
    a[i] = pairt[i].first;
    b[i] = pairt[i].second;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long isPrime(long long n) {
  if (n < 2) return 0;
  if (n < 4) return 1;
  if (n % 2 == 0 or n % 3 == 0) return 0;
  for (long long i = 5; i * i <= n; i += 6)
    if (n % i == 0 or n % (i + 2) == 0) return 0;
  return 1;
}
long long C(long long n, long long r) {
  if (r > n - r) r = n - r;
  long long ans = 1;
  long long i;
  for (i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }
  return ans;
}
long long modexpo(long long x, long long p) {
  long long res = 1;
  x = x % mod;
  while (p) {
    if (p % 2) res = res * x;
    p >>= 1;
    x = x * x % mod;
    res %= mod;
  }
  return res;
}
long long power(long long x, long long y, long long p = mod) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
string multiply(string num1, string num2) {
  long long len1 = num1.size();
  long long len2 = num2.size();
  if (len1 == 0 || len2 == 0) return "0";
  vector<long long> result(len1 + len2, 0);
  long long i_n1 = 0;
  long long i_n2 = 0;
  for (long long i = len1 - 1; i >= 0; i--) {
    long long carry = 0;
    long long n1 = num1[i] - '0';
    i_n2 = 0;
    for (long long j = len2 - 1; j >= 0; j--) {
      long long n2 = num2[j] - '0';
      long long sum = n1 * n2 + result[i_n1 + i_n2] + carry;
      carry = sum / 10;
      result[i_n1 + i_n2] = sum % 10;
      i_n2++;
    }
    if (carry > 0) result[i_n1 + i_n2] += carry;
    i_n1++;
  }
  long long i = result.size() - 1;
  while (i >= 0 && result[i] == 0) i--;
  if (i == -1) return "0";
  string s = "";
  while (i >= 0) s += std::to_string(result[i--]);
  return s;
}
long long sti(string s) {
  long long ans = 0;
  long long p = 1;
  for (long long i = s.size() - 1; i >= 0; i--) {
    ans = (ans + ((long long)(s[i] - '0') * p) % mod) % mod;
    p = (p * 10) % mod;
  }
  return ans;
}
void printArr(long long a[], long long n) {
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
void printVector(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void printVectorPair(vector<pair<long long, long long>> v) {
  for (long long i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << "\n";
  ;
  cout << "\n";
}
void time() {}
const long long N = 1e6 + 5;
const long long despacito = 1e9 + 7;
long long n, m, x, suma, sumb, ans;
vector<long long> a, b;
vector<pair<long long, long long>> idx;
map<long long, pair<long long, long long>> mp;
map<long long, pair<long long, long long>>::iterator it;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  a.push_back(-100);
  for (long long i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
    suma += x;
  }
  b.push_back(-100);
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> x;
    b.push_back(x);
    sumb += x;
  }
  ans = abs(suma - sumb);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      long long tmp = abs(suma - 2 * a[i] + 2 * b[j] - sumb);
      if (tmp < ans) {
        idx.clear();
        ans = tmp;
        idx.push_back({i, j});
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      mp[2 * (a[i] + a[j])] = pair<long long, long long>(i, j);
    }
  }
  for (long long i = 1; i <= m; i++) {
    for (long long j = i + 1; j <= m; j++) {
      long long tmp = suma - sumb + 2 * (b[i] + b[j]);
      it = mp.lower_bound(tmp);
      if (it != mp.begin()) it--;
      for (long long k = 0; k < 2; k++) {
        if (it == mp.end()) break;
        long long u = abs(tmp - it->first);
        pair<long long, long long> v = it->second;
        if (u < ans) {
          idx.clear();
          ans = u;
          idx.push_back({v.first, i});
          idx.push_back({v.second, j});
        }
        it++;
      }
    }
  }
  cout << ans << "\n";
  cout << idx.size() << "\n";
  for (long long i = 0; i < idx.size(); i++) {
    cout << idx[i].first << " " << idx[i].second << "\n";
  }
  return 0;
}