#include <bits/stdc++.h>
using namespace std;
const int maxn = 112345;
int n, m, y, a[maxn], b[maxn], res;
map<int, int> mp;
int main() {
  scanf("%d%d", &n, &y);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]), res = max(res, ++mp[a[i]]);
  scanf("%d%d", &m, &y);
  for (int i = 0; i < m; ++i) scanf("%d", &b[i]), res = max(res, ++mp[b[i]]);
  for (int i = 1; i < 1 << 30; i = i + i) {
    mp.clear();
    for (int j = 0; j < n; ++j) res = max(res, ++mp[(a[j] + i) % (i + i)]);
    for (int j = 0; j < m; ++j) res = max(res, ++mp[b[j] % (i + i)]);
  }
  printf("%d\n", res);
  return 0;
}
