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 double PI = 3.1415926;
template <typename T>
T gcd(T a, T b) {
  while (b) {
    T c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <typename T>
T lcm(T a, T b) {
  assert(a / gcd(a, b) <= numeric_limits<T>::max() / b);
  return a * (b / gcd(a, b));
}
class out {
 public:
  template <typename T>
  out &operator()(const T &t) {
    cout << t << ' ';
    return *this;
  }
  template <typename T1, typename T2>
  out &operator()(const pair<T1, T2> &t) {
    cout << '(' << t.first << ',' << t.second << ')' << ' ';
    return *this;
  }
};
template <typename iter>
inline void print_(iter beg, iter end) {
  cout << endl;
  for_each(beg, end, out());
  cout << endl;
}
template <typename T>
inline void print_(const T &t) {
  cout << endl << t << endl;
}
inline void print_(const char *t) { cout << endl << t << endl; }
template <typename T, unsigned int M>
inline void print_(const T (&t)[M]) {
  cout << endl;
  for (unsigned int i = 0; i < M; ++i) {
    cout << t[i] << ' ';
  }
  cout << endl;
}
template <typename T, unsigned int M>
inline void print_(const T (&t)[M], unsigned int c) {
  cout << endl;
  for (unsigned int i = 0; i < c; ++i) {
    cout << t[i] << ' ';
  }
  cout << endl;
}
template <typename T, unsigned int M, unsigned int N>
inline void print_(const T (&t)[M][N]) {
  cout << endl;
  for (unsigned int i = 0; i < M; ++i) {
    for (unsigned int j = 0; j < N; ++j) {
      cout << t[i][j] << ' ';
    }
    cout << endl;
  }
}
template <typename T, unsigned int M, unsigned int N>
inline void print_(const T (&t)[M][N], unsigned int r, unsigned int c) {
  cout << endl;
  for (unsigned int i = 0; i < r; ++i) {
    for (unsigned int j = 0; j < c; ++j) {
      cout << t[i][j] << ' ';
    }
    cout << endl;
  }
}
template <typename T>
inline int BKDRHash(const T *str) {
  register int hash = 0;
  while (int ch = (int)*str++) {
    hash = hash * 131 + ch;
  }
  return hash;
}
template <typename T>
inline T powxy(T x, int y) {
  T r;
  for (r = 1; y > 0; --y) r *= x;
  return r;
}
inline unsigned long long factorial(unsigned long long n) {
  unsigned long long r;
  for (r = 1; n > 0; --n) r *= n;
  return r;
}
inline unsigned long long permutation(unsigned long long n,
                                      unsigned long long k) {
  unsigned long long r = 1;
  while (k--) r *= n--;
  return r;
}
inline unsigned long long combination(unsigned long long n,
                                      unsigned long long k) {
  return permutation(n, k) / factorial(k);
}
int n, m;
long long int suma, sumb;
int a[2001];
int b[2001];
struct s {
  int i;
  int j;
  long long int d;
  s(const s &rs) : i(rs.i), j(rs.j), d(rs.d) {}
  s(int i_, int j_, long long int d_) : i(i_), j(j_), d(d_) {}
  s &operator=(const s &rs) {
    i = rs.i;
    j = rs.j;
    d = rs.d;
    return *this;
  }
};
ostream &operator<<(ostream &os, const s &rs) {
  os << rs.i << '|' << rs.j << '|' << rs.d;
}
bool operator<(const s &l, const s &r) { return l.d < r.d; }
vector
 vs;
vector<pair<int, int> > vp;
long long int solve() {
  long long int mi = suma - sumb;
  if (mi < 0) mi = -mi;
  for (unsigned int k = 0; k < vs.size(); ++k) {
    long long int d = suma - sumb - vs[k].d;
    if (d < 0) d = -d;
    if (d < mi) {
      vp.clear();
      vp.push_back(make_pair(vs[k].j, vs[k].i));
      mi = d;
    }
    pair<vector
::iterator, vector
::iterator> t =
        equal_range(vs.begin(), vs.end(), s(0, 0, suma - sumb - vs[k].d));
    if (t.first > vs.begin()) --t.first;
    if (t.second < vs.end()) ++t.second;
    for (; t.first != t.second; ++t.first) {
      if (t.first->i != vs[k].i && t.first->j != vs[k].j) {
        d = suma - sumb - vs[k].d - t.first->d;
        if (d < 0) d = -d;
        if (d < mi) {
          vp.clear();
          vp.push_back(make_pair(vs[k].j, vs[k].i));
          vp.push_back(make_pair(t.first->j, t.first->i));
          mi = d;
        }
      }
    }
  }
  return mi;
}
int main() {
  vs.reserve(sizeof(s) * 1000000);
  scanf("%d", &n);
  for (int j = 1; j <= n; ++j) {
    scanf("%d", a + j);
    suma += *(a + j);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", b + i);
    sumb += *(b + i);
    for (int j = 1; j <= n; ++j) {
      vs.push_back(s(i, j, 2 * (long long int)(*(a + j) - *(b + i))));
    }
  }
  sort(vs.begin(), vs.end());
  (vs.begin(), vs.end());
  cout << abs(solve()) << endl;
  printf("%d\n", vp.size());
  for (unsigned int i = 0; i < vp.size(); ++i) {
    printf("%d %d\n", vp[i].first, vp[i].second);
  }
  return 0;
}