#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N], b[N];
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);
  for (int i = 0; i < m; i++) {
    scanf("%d", b + i);
  }
  int ans = 0;
  for (long long d = 2; d <= (int)2e9; d *= 2) {
    map<int, int> a_mods, b_mods;
    for (int i = 0; i < n; i++) {
      a_mods[a[i] % d]++;
    }
    for (int i = 0; i < m; i++) {
      b_mods[b[i] % d]++;
    }
    for (auto &x : a_mods) {
      int my_mod = x.first;
      int my_count = x.second;
      int his_mod = (my_mod + d / 2) % d;
      ans = max(ans, my_count + b_mods[his_mod]);
    }
    for (auto &x : b_mods) {
      int my_mod = x.first;
      int my_count = x.second;
      int his_mod = (my_mod + d / 2) % d;
      ans = max(ans, my_count + a_mods[his_mod]);
    }
  }
  set<int> have;
  for (int i = 0; i < n; i++) {
    have.insert(a[i]);
  }
  for (int i = 0; i < m; i++) {
    if (have.count(b[i])) {
      ans = max(ans, 2);
    }
  }
  printf("%d\n", ans);
  return 0;
}
