#include <bits/stdc++.h>
using namespace std;
using INT = long long;
int a[200100], b[200100];
map<int, int> mp[2];
int arr[200100];
map<int, int> vst;
int main() {
  int n, st;
  cin >> n >> st;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int m, ed;
  cin >> m >> ed;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
  }
  int d = 1;
  int ans = 1;
  for (int j = 1; j <= 30; j++) {
    mp[0].clear();
    mp[1].clear();
    int x = (1 << j);
    int nn = 0;
    for (int i = 1; i <= n; i++) {
      int r = a[i] % x;
      mp[0][r]++;
      ans = max(ans, mp[0][r]);
      arr[++nn] = r;
    }
    for (int i = 1; i <= m; i++) {
      int r = b[i] % x;
      mp[1][r]++;
      ans = max(ans, mp[1][r] + mp[0][(r + x / 2) % x]);
      arr[++nn] = r;
    }
  }
  for (int i = 1; i <= n; i++) vst[a[i]] = 1;
  for (int i = 1; i <= m; i++)
    if (vst[b[i]]) ans = max(ans, 2);
  cout << ans << endl;
}
