#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int INF = 2147483647;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
int A[maxn], B[maxn];
map<int, int> mp1, mp2;
int main() {
  int n, y1;
  scanf("%d%d", &n, &y1);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  int m, y2;
  scanf("%d%d", &m, &y2);
  int ma = 2;
  for (int i = 0; i < m; i++) scanf("%d", &B[i]);
  for (int i = 1; i <= 30; i++) {
    int x = (1 << i);
    for (int j = 0; j < n; j++) mp1[A[j] % x]++;
    for (int j = 0; j < m; j++) mp2[B[j] % x]++;
    for (auto it : mp1) {
      auto it2 = mp2.find((it.first + x / 2) % x);
      if (it2 != mp2.end())
        ma = max(ma, it.second + it2->second);
      else
        ma = max(ma, it.second);
    }
    for (auto it : mp2) {
      auto it2 = mp1.find((it.first + x / 2) % x);
      if (it2 != mp1.end())
        ma = max(ma, it.second + it2->second);
      else
        ma = max(ma, it.second);
    }
    mp1.clear();
    mp2.clear();
  }
  printf("%d\n", ma);
  return 0;
}
