#include <bits/stdc++.h>
using namespace std;
int ans = 2, n, m, fqfq, y2, a[100005], b[100005];
map<int, int> rsa, rsb;
void test(int it) {
  int sin = it >> 1;
  rsa.clear();
  rsb.clear();
  for (int i = 0; i < n; ++i) ++rsa[a[i] % it];
  for (int i = 0; i < m; ++i) ++rsb[b[i] % it];
  for (auto& x : rsa) {
    int tans = x.second;
    auto jt = rsb.find((x.first + sin) % it);
    if (jt != rsb.end()) tans += jt->second;
    ans = max(ans, std::remove_reference<decltype(ans)>::type(tans));
  }
  for (auto& x : rsb) {
    int tans = x.second;
    auto jt = rsa.find((x.first + sin) % it);
    if (jt != rsa.end()) tans += jt->second;
    ans = max(ans, std::remove_reference<decltype(ans)>::type(tans));
  }
}
int main() {
  scanf("%d%d", &n, &fqfq);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  scanf("%d%d", &m, &y2);
  for (int i = 0; i < m; ++i) scanf("%d", b + i);
  for (int i = 1; i < 30; ++i) test(1 << i);
  printf("%d\n", ans);
}
