#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, y;
  vector<pair<int, int> > p;
  cin >> n >> y;
  for (int i = (1); i <= (n); ++i) {
    int x;
    cin >> x;
    p.push_back(pair<int, int>(x, 0));
  }
  cin >> m >> y;
  for (int i = (1); i <= (m); ++i) {
    int x;
    cin >> x;
    p.push_back(pair<int, int>(x, 1));
  }
  sort(p.begin(), p.end());
  int ans = 2;
  for (long long l = 1; l <= 1e9; l *= 2) {
    map<int, int> dp[2];
    int f = 1;
    for (pair<int, int> x : p) {
      f = max(dp[x.second][x.first % (2 * l)],
              dp[1 - x.second][(x.first + l) % (2 * l)]) +
          1;
      dp[x.second][x.first % (2 * l)] = f;
      ans = max(ans, f);
    }
  }
  cout << ans;
}
