#include <bits/stdc++.h>
using namespace std;
int n, m, y;
int a[101101], b[101101];
map<int, int> mpa, mpb;
map<int, int>::iterator it;
set<int> st;
int calc(int gap) {
  int x = gap * 2, res = 0;
  mpa.clear();
  mpb.clear();
  for (int i = 0; i < n; i++) mpa[a[i] % x]++;
  for (int i = 0; i < m; i++) mpb[b[i] % x]++;
  for (it = mpa.begin(); it != mpa.end(); it++) {
    long long cur = (*it).first, nxt = 1LL * cur + gap;
    if (nxt >= x) nxt -= x;
    res = max(res, (*it).second + mpb[nxt]);
  }
  for (it = mpb.begin(); it != mpb.end(); it++) {
    long long cur = (*it).first, nxt = 1LL * cur + gap;
    if (nxt >= x) nxt -= x;
    res = max(res, (*it).second + mpa[nxt]);
  }
  return res;
}
int main() {
  int ans = 1;
  scanf("%d%d", &n, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    st.insert(a[i]);
  }
  scanf("%d%d", &m, &y);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    if (st.find(b[i]) != st.end()) ans = 2;
  }
  for (int gap = 1; gap <= int(1e9); gap *= 2) {
    ans = max(ans, calc(gap));
  }
  printf("%d\n", ans);
  return 0;
}
