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;
using PII = pair<int, int>;
class Event {
 public:
  int i, j;
  long long value;
  Event(int i = 0, int j = 0, long long value = 0) : i(i), j(j), value(value){};
  bool operator<(const Event &rhs) const { return value < rhs.value; }
};
vector<long long> a, b;
vector<Event> pairs;
int n, m;
void read(vector<long long> &a, int &Size) {
  cin >> Size;
  a.resize(Size);
  for (int i = 0; i < Size; ++i) cin >> a[i];
}
long long S(vector<long long> &a) {
  long long all = 0;
  for (const auto &X : a) all += X;
  return all;
}
pair<long long, vector<int>> init() {
  long long dif = S(a) - S(b);
  pair<long long, vector<int>> V(abs(dif), {0});
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      long long result = abs(dif - 2LL * a[i] + 2LL * b[j]);
      if (result < V.first) {
        V.first = result;
        vector<int> vec = {i, j};
        V.second = vec;
      }
    }
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      Event tmp(i, j, 2LL * a[i] + 2LL * a[j]);
      pairs.push_back(tmp);
    }
  sort(pairs.begin(), pairs.end());
  return V;
}
Event after(long long how) {
  int st = 0, dr = pairs.size() - 1;
  Event ret(-1, -1, -1);
  while (st <= dr) {
    int m = (st + dr) >> 1;
    if (pairs[m].value >= how) {
      ret = pairs[m];
      dr = m - 1;
    } else
      st = m + 1;
  }
  return ret;
}
Event before(long long how) {
  int st = 0, dr = pairs.size() - 1;
  Event ret(-1, -1, -1);
  while (st <= dr) {
    int m = (st + dr) >> 1;
    if (pairs[m].value <= how) {
      ret = pairs[m];
      st = m + 1;
    } else
      dr = m - 1;
  }
  return ret;
}
void schimb(pair<long long, vector<int>> &p, int i, int j, const Event &lhs) {
  if (lhs.value == -1 || lhs.value >= p.first || lhs.i == -1 || lhs.j == -1)
    return;
  p.first = lhs.value;
  vector<int> vec = {lhs.i, i, lhs.j, j};
  p.second = vec;
}
void solve() {
  auto ret = init();
  long long Dif = S(a) - S(b);
  for (int i = 0; i < m; ++i)
    for (int j = i + 1; j < m; ++j) {
      long long now = Dif + 2LL * (b[i] + b[j]);
      Event Aft = after(now), Bef = before(now);
      Aft.value = abs(Aft.value - now), Bef.value = abs(Bef.value - now);
      schimb(ret, i, j, Aft), schimb(ret, i, j, Bef);
    }
  cout << ret.first << '\n' << ret.second.size() / 2 << '\n';
  if (ret.second.size() > 1)
    for (int i = 0; i < ret.second.size(); i++) {
      assert(ret.second[i] != -1);
      cout << ret.second[i] + 1 << '\n';
    }
}
int main() {
  read(a, n), read(b, m);
  solve();
}