#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();
}
