#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		map<long long, long long> m1;
		long long m = xx /2;
		for (long i : vecx) {
			m1[i & (2 * m-1)]++;
			m2[(i + xx) & (2 * m - 1)]++;
		}
		for (long i : vecy) {
			m2[i & (2 * m-1)]++;
			m1[(i + xx) & (2 * m-1)]++;
		}
		for (auto i : m1) {
			max1 = max(max1, i.second);
		}
		for (auto i : m2) {
			max2 = max(max2, i.second);
		}
		if (xx == 0)xx == 1;
	}

	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	/*for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}*/
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
		}
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		for (long i : vecx) {
			m1[i % (2 * xx)]++;
			// m2[(i + xx) % (2 * xx)]++;
		}
		for (long i : vecy) {
			// m2[i % (2 * xx)]++;
			m1[(i + xx) % (2 * xx)]++;
		}
	}
	for (auto i : m1) {
		max1 = max(max1, i.second);
	}
	for (auto i : m2) {
		//max2 = max(max2, i.second);
	}
	//long long ot = max(max1,max2);
	cout << max1;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
		}
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xmin;
	long long ymin;
	cin >> xmin;
	vecx.push_back(0);
	for (int i = 1; i < x; i++) {
		cin >> a;
		vecx.push_back(a-xmin);
	}
	cin >> y >> a;
	cin >> ymin;
	vecx.push_back(0);
	for (int i = 1; i < y; i++) {
		cin >> a;
		vecy.push_back(a-ymin);
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 1000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
		}
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		map<long long, long long> m1;
		for (long i : vecx) {
			m1[i % (2 * xx)]++;
			// m2[(i + xx) % (2 * xx)]++;
		}
		for (long i : vecy) {
			// m2[i % (2 * xx)]++;
			m1[(i + xx) % (2 * xx)]++;
		}
		for (auto i : m1) {
			max1 = max(max1, i.second);
		}
	}

	for (auto i : m2) {
		//max2 = max(max2, i.second);
	}
	//long long ot = max(max1,max2);
	cout << max1;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	for (long long xx = 1; xx < 1000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0)
				m1[xx]++;
			if ((i + xx) % (2 * xx) == 0)
				m2[xx]++;
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0)
				m2[xx]++;
			if ((i + xx) % (2 * xx) == 0)
				m1[xx]++;
		}
	}
	long long ot = max(m1.max_size(), m2.max_size());
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
			}
			if ((i + xx) % (2 * xx) == 0){
				m2[xx]++;
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m2[xx]++;
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
			}
		}
	}
	for (auto i : m1) {
		max1 = max(max1, i.second);
	}
	for (auto i : m2) {
		max2 = max(max2, i.second);
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		for (long i : vecx) {
			m1[i % (2 * xx)]++;
			m2[(i + xx) % (2 * xx)]++;
		}
		for (long i : vecy) {
			m2[i % (2 * xx)]++;
			m1[(i + xx) % (2 * xx)]++;
		}
	}
	for (auto i : m1) {
		max1 = max(max1, i.second);
	}
	for (auto i : m2) {
		max2 = max(max2, i.second);
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 0; xx < 10000000000; xx *= 2) {
		map<long long, long long> m1;
		for (long i : vecx) {
			m1[i & (2 * xx-1)]++;
			// m2[(i + xx) % (2 * xx)]++;
		}
		for (long i : vecy) {
			// m2[i % (2 * xx)]++;
			m1[(i + xx) & (2 * xx-1)]++;
		}
		for (auto i : m1) {
			max1 = max(max1, i.second);
		}
		if (xx == 0)xx == 1;
	}

	for (auto i : m2) {
		//max2 = max(max2, i.second);
	}
	//long long ot = max(max1,max2);
	cout << max1;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 1000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
		}
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;

	for (int i = 1; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 1000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m2[xx]++;
				max2 = max(max2, m2[xx]);
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
				max1 = max(max1, m1[xx]);
			}
		}
	}
	long long ot = max(max1,max2);
	cout << ot;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		map<long long, long long> m1;
		long long m = xx >> 1;
		for (long i : vecx) {
			m1[i & (2 * m-1)]++;
			// m2[(i + xx) % (2 * xx)]++;
		}
		for (long i : vecy) {
			// m2[i % (2 * xx)]++;
			m1[(i + xx) & (2 * m-1)]++;
		}
		for (auto i : m1) {
			max1 = max(max1, i.second);
		}
		if (xx == 0)xx == 1;
	}

	for (auto i : m2) {
		//max2 = max(max2, i.second);
	}
	//long long ot = max(max1,max2);
	cout << max1;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int x, y;
	long a;
	cin >> x >>a;
	vector<long> vecx;
	vector<long> vecy;
	long long xymin;
	for (int i = 0; i < x; i++) {
		cin >> a;
		vecx.push_back(a);
	}
	cin >> y >> a;
	for (int i = 0; i < y; i++) {
		cin >> a;
		vecy.push_back(a);
	}
	xymin = min(vecx[0], vecy[0]);
	for (int i = 0; i < x; i++) {
		vecx[i] -= xymin;
	}
	for (int i = 0; i < y; i++) {
		vecy[i] -= xymin;
	}
	long long xx = 1;
	map<long long, long long> m1;
	map<long long, long long> m2;
	long long max1 = 0, max2 = 0;
	for (long long xx = 1; xx < 10000000000; xx *= 2) {
		for (long i : vecx) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
			}
		}
		for (long i : vecy) {
			if (i % (2 * xx) == 0) {
				m1[xx]++;
			}
			if ((i + xx) % (2 * xx) == 0){
				m1[xx]++;
			}
		}
	}
	for (auto i : m1) {
		max1 = max(max1, i.second);
	}
	for (auto i : m2) {
		//max2 = max(max2, i.second);
	}
	//long long ot = max(max1,max2);
	cout << max1;
}


// Problem : F. Ray in the tube
// Contest : Codeforces Round #509 (Div. 2)
// URL : https://codeforces.com/contest/1041/problem/F
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
map<int,int> has, md;
int main () {
	int n,y1,m;
	scanf ("%d %d",&n,&y1);
	vector<int> x1(n);
	for (auto &au : x1) scanf ("%d",&au), ++has[au];
	scanf ("%d %d",&m,&y1);
	vector<int> x2(m);
	int ans = 0;
	for (auto &au : x2) {
		scanf ("%d",&au);
		if (has[au]) ans = max(ans,2);
	}
	for (int diff = 1; diff <= 1e9; diff <<= 1) {
		md.clear();
		for (int i : x1) ans=max(ans,++md[i%diff]);
		for (int i : x2) ans=max(ans,++md[(i+diff/2)%diff]);
	}
	printf ("%d\n",ans);
	return 0;
}


// Problem : F. Ray in the tube
// Contest : Codeforces Round #509 (Div. 2)
// URL : https://codeforces.com/contest/1041/problem/F
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
map<int,int> has, md;
int main () {
	int n,y1,m;
	scanf ("%d %d",&n,&y1);
	vector<int> x1(n);
	for (auto &au : x1) scanf ("%d",&au), ++has[au];
	scanf ("%d %d",&m,&y1);
	vector<int> x2(m);
	int ans = max(n,m);
	assert(m!=32000);
	for (auto &au : x2) {
		scanf ("%d",&au);
		if (has[au]) ans = max(ans,2);
	}
	for (int diff = 2; diff <= 1e9; diff <<= 1) {
		md.clear();
		for (int i : x1) ans=max(ans,++md[i%diff]);
		for (int i : x2) ans=max(ans,++md[(i+diff/2)%diff]);
	}
	printf ("%d\n",ans);
	return 0;
}


// Problem : F. Ray in the tube
// Contest : Codeforces Round #509 (Div. 2)
// URL : https://codeforces.com/contest/1041/problem/F
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
map<int,int> has, md;
int main () {
	int n,y1,m;
	scanf ("%d %d",&n,&y1);
	vector<int> x1(n);
	for (auto &au : x1) scanf ("%d",&au), ++has[au];
	scanf ("%d %d",&m,&y1);
	vector<int> x2(m);
	int ans = 0;
	for (auto &au : x2) {
		scanf ("%d",&au);
		if (has[au]) ans = max(ans,2);
	}
	for (int diff = 2; diff <= 1e9; diff <<= 1) {
		md.clear();
		for (int i : x1) ans=max(ans,++md[i%diff]);
		for (int i : x2) ans=max(ans,++md[(i+diff/2)%diff]);
	}
	printf ("%d\n",ans);
	return 0;
}


// Problem : F. Ray in the tube
// Contest : Codeforces Round #509 (Div. 2)
// URL : https://codeforces.com/contest/1041/problem/F
// Memory Limit : 256.000000 MB
// Time Limit : 2000.000000 milisec
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using ld = long double;
#define all(x) (x).begin(),(x).end()
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
map<int,int> has, md;
int main () {
	int n,y1,m;
	scanf ("%d %d",&n,&y1);
	vector<int> x1(n);
	for (auto &au : x1) scanf ("%d",&au), ++has[au];
	scanf ("%d %d",&m,&y1);
	vector<int> x2(m);
	int ans = max(n,m);
	for (auto &au : x2) {
		scanf ("%d",&au);
		if (has[au]) ans = max(ans,2);
	}
	for (int diff = 2; diff <= 1e9; diff <<= 1) {
		md.clear();
		for (int i : x1) ans=max(ans,++md[i%diff]);
		for (int i : x2) ans=max(ans,++md[(i+diff/2)%diff]);
	}
	printf ("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std ;

#define MAXN 100007

int n , m ;
int a[ MAXN ] ;
int b[ MAXN ] ;

map < int , int > w ;

void input ( ) {
    scanf ( "%d%*d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
    scanf ( "%d%*d" , &m ) ;
    for ( int i = 1 ; i <= m ; ++ i ) {
        scanf ( "%d" , &b[ i ] ) ;
    }
}

void solve ( ) {
    int ans = 2 ;
    for ( int i = 0 ; i < 30 ; ++ i ) {
        int len = (1<<i) ;
        w.clear ( ) ;
        for ( int i = 1 ; i <= n ; ++ i ) {
            int val = ( a[ i ] % ( 2 * len ) ) ;
            ++ w[ val ] ;
            if ( ans < w[ val ] ) { ans = w[ val ] ; }
        }
        for ( int i = 1 ; i <= m ; ++ i ) {
            int val = ( ( b[ i ] + len ) % ( 2 * len ) ) ;
            ++ w[ val ] ;
            if ( ans < w[ val ] ) { ans = w[ val ] ; }
        }
    }
    cout << ans << "\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;

#define MAXN 100007

int n , m ;
int a[ MAXN ] ;
int b[ MAXN ] ;

map < int , int > w ;

void input ( ) {
    scanf ( "%d%*d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
    scanf ( "%d%*d" , &m ) ;
    for ( int i = 1 ; i <= m ; ++ i ) {
        scanf ( "%d" , &b[ i ] ) ;
    }
}

void solve ( ) {
    int ans = 0 ;
    for ( int i = 0 ; i <= 30 ; ++ i ) {
        int len = (1<<i) ;
        w.clear ( ) ;
        for ( int i = 1 ; i <= n ; ++ i ) {
            int val = ( a[ i ] % ( 2 * len ) ) ;
            ++ w[ val ] ;
            if ( ans < w[ val ] ) { ans = w[ val ] ; }
        }
        for ( int i = 1 ; i <= m ; ++ i ) {
            int val = ( ( b[ i ] + len ) % ( 2 * len ) ) ;
            ++ w[ val ] ;
            if ( ans < w[ val ] ) { ans = w[ val ] ; }
        }
    }
    cout << ans << "\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;

#define MAXN 100007

int n , m ;
int a[ MAXN ] ;
int b[ MAXN ] ;

map < int , int > w ;

void input ( ) {
    scanf ( "%d%*d" , &n ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
    scanf ( "%d%*d" , &m ) ;
    for ( int i = 1 ; i <= m ; ++ i ) {
        scanf ( "%d" , &b[ i ] ) ;
    }
}

void solve ( ) {
    int ans = 0 ;
    for ( int i = 0 ; i < 30 ; ++ i ) {
        int len = (1<<i) ;
        w.clear ( ) ;
        for ( int i = 1 ; i <= n ; ++ i ) {
            int val = ( a[ i ] % ( 2 * len ) ) ;
            ++ w[ val ] ;
            if ( ans < w[ val ] ) { ans = w[ val ] ; }
        }
        for ( int i = 1 ; i <= m ; ++ i ) {
            int val = ( ( b[ i ] + len ) % ( 2 * len ) ) ;
            ++ w[ val ] ;
            if ( ans < w[ val ] ) { ans = w[ val ] ; }
        }
    }
    cout << ans << "\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<ll> vi;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, y1, m, y2;
	cin >> n >> y1;
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	cin >> m >> y2;
	vi b(m);
	for(int i = 0; i < m; i++) cin >> b[i];

	int ans = 2;
	for(ll len = 2; len < 1e9; len <<= 1){
		unordered_map<ll, int> umap;
		for(int i = 0; i < n; i++) umap[a[i] % len]++;
		for(int i = 0; i < m; i++) umap[(b[i] + len / 2) % len]++;
		for(auto u : umap) ans = max(ans, u.se);

	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef vector<int> vi;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, y1, m, y2;
	cin >> n >> y1 >> m >> y2;
	vi a(n), b(m);

	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < m; i++) cin >> b[i];

	int ans = 2;
	for(int len = 2; len < 1e9; len <<= 1){
		unordered_map<int, int> umap;
		for(int i = 0; i < n; i++) umap[a[i] % len]++;
		for(int i = 0; i < m; i++) umap[(a[i] - len / 2) % len]++;
		for(auto u : umap) ans = max(ans, u.se);
	}

	cout << ans << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef vector<int> vi;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, y1, m, y2;
	cin >> n >> y1;
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	cin >> m >> y2;
	vi b(m);
	for(int i = 0; i < m; i++) cin >> b[i];

	int ans = 2;
	for(ll len = 2; len < 1e9; len <<= 1){
		unordered_map<int, int> umap;
		for(int i = 0; i < n; i++) umap[a[i] % len]++;
		for(int i = 0; i < m; i++) umap[(b[i] - len / 2) % len]++;
		for(auto u : umap) ans = max(ans, u.se);
		umap.clear();
	}

	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

const int N = 100 * 1000 + 4;
const int LG = 30;

int n, m;
long long mod, ans;
int arr[N], brr[N];
map <long long, long long> A, B;

void input() {
    cin.tie(0);
    int useless;

    cin >> n >> useless;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    cin >> m >> useless;
    for (int i = 0; i < m; i++)
        cin >> brr[i];
}

void solve() {
    sort(arr, arr + n);
    for (int i = 0; i < m; i++)
        if (brr[lower_bound(arr, arr + n, brr[i]) - arr] == brr[i])
            ans = 2;

    for (mod = 1; mod <= (1 << LG); mod <<= 1) {
        for (int i = 0; i < n; i++)
            A[arr[i] & (2 * mod - 1)]++;
        for (int i = 0; i < m; i++)
            B[brr[i] & (2 * mod - 1)]++;

        for (auto p : A)
            ans = max(ans, p.second + B[(p.first + mod) % (2 * mod)]);
        for (auto p : B)
            ans = max(ans, p.second + A[(p.first + mod) % (2 * mod)]);
        A.clear(), B.clear();
    }
}

int main() {
    ios::sync_with_stdio(false);
    input();
    solve();
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

const int N = 100 * 1000 + 4;
const int LG = 30;

int n, m;
long long mod, ans;
int arr[N], brr[N];
map <long long, long long> A, B;

void input() {
    cin.tie(0);
    int useless;

    cin >> n >> useless;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    cin >> m >> useless;
    for (int i = 0; i < m; i++)
        cin >> brr[i];
}

void solve() {
    for (mod = 1; mod <= (1 << LG); mod <<= 1) {
        for (int i = 0; i < n; i++)
            A[arr[i] & (2 * mod - 1)]++;
        for (int i = 0; i < m; i++)
            B[brr[i] & (2 * mod - 1)]++;

        for (auto p : A)
            ans = max(ans, p.second + B[(p.first + mod) % (2 * mod)]);
        for (auto p : B)
            ans = max(ans, p.second + A[(p.first + mod) % (2 * mod)]);
        A.clear(), B.clear();
    }
}

int main() {
    ios::sync_with_stdio(false);
    input();
    solve();
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

const int N = 100 * 1000 + 4;
const int LG = 30;

int n, m, ans;
long long mod;
int arr[N], brr[N];
map <int, int> A, B;

void input() {
    cin.tie(0);
    int useless;

    cin >> n >> useless;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    cin >> m >> useless;
    for (int i = 0; i < m; i++)
        cin >> brr[i];
}

void solve() {
    for (mod = 1; mod <= (1 << LG); mod <<= 1) {
        for (int i = 0; i < n; i++)
            A[arr[i] & (2 * mod - 1)]++;
        for (int i = 0; i < m; i++)
            B[brr[i] & (2 * mod - 1)]++;

        for (pair <int, int> p : A)
            ans = max(ans, p.second + B[(p.first + mod) % (2 * mod)]);
        A.clear(), B.clear();
    }
}

int main() {
    ios::sync_with_stdio(false);
    input();
    solve();
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int up[maxn],down[maxn];
map<int ,int >mp;
int main()
{
    int n,y1,m,y2;
    scanf("%d%d",&n,&y1);
    for(int i=0;i<n;i++){
        scanf("%d",&down[i]);
    }
    scanf("%d%d",&m,&y2);
    for(int i=0;i<m;i++){
        scanf("%d",&up[i]);
    }
    int ans=2;
    for(int len=2;len<=1e9;len<<=1){
        mp.clear();
        for(int i=0;i<n;i++){
            mp[down[i]%len]++;
            ans=max(ans,mp[down[i]%len]);
        }
        for(int i=0;i<m;i++){
            int tmp=up[i]%len+len>>1;
            mp[tmp]++;
            ans=max(ans,mp[tmp]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int up[maxn],down[maxn];
map<int ,int >mp;
int main()
{
    int n,y1,m,y2;
    scanf("%d%d",&n,&y1);
    for(int i=0;i<n;i++){
        scanf("%d",&up[i]);
    }
    scanf("%d%d",&m,&y2);
    for(int i=0;i<m;i++){
        scanf("%d",&down[i]);
    }
    int ans=0;
    for(int len=2;len<=1e9;len<<=1){
        mp.clear();
        for(int i=0;i<n;i++){
            mp[up[i]%len]++;
            ans=max(ans,mp[up[i]%len]);
        }
        for(int i=0;i<m;i++){
            int tmp=down[i]%len+len>>1;
            mp[tmp]++;
            ans=max(ans,mp[tmp]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int up[maxn],down[maxn];
map<int ,int >mp;
int main()
{
    int n,y1,m,y2;
    scanf("%d%d",&n,&y1);
    for(int i=0;i<n;i++){
        scanf("%d",&down[i]);
    }
    scanf("%d%d",&m,&y2);
    for(int i=0;i<m;i++){
        scanf("%d",&up[i]);
    }
    int ans=2;
    for(int len=2;len<=1e9;len<<=1){
        mp.clear();
        for(int i=0;i<n;i++){
            mp[down[i]%len]++;
            ans=max(ans,mp[down[i]%len]);
        }
        for(int i=0;i<m;i++){
            int tmp=(up[i]+len/2)%len;
            mp[tmp]++;
            ans=max(ans,mp[tmp]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
const int SZ = 200010;
const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const LD eps = 1e-8;

LL read() {
    LL n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a <= '9' && a >= '0') { n = n * 10 + a - '0',a = getchar(); }
	if(flag) n = -n;
	return n;
}

int n,m,a[SZ],b[SZ];
map<LL,LL> a2,a4,b2,b4;

int main() {
	int n = read(),y1 = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	int m = read(),y2 = read();
	for(int i = 1;i <= m;i ++) b[i] = read();
	int d = y2 - y1;
	for(int i = 1;i <= n;i ++) {
		LL p1 = 2ll * d;
		LL p2 = 4ll * d;
		a2[a[i] % p1] ++;
		a4[a[i] % p2] ++;
	}
	for(int i = 1;i <= m;i ++) {
		LL p1 = 2ll * d;
		LL p2 = 4ll * d;
		b2[b[i] % p1] ++;
		b4[b[i] % p2] ++;
	}
	LL ans = 0;
	for(int i = 1;i <= n;i ++) {
		LL p2 = 2ll * d;
		LL p4 = 4ll * d;
		LL x = a2[a[i] % p2],y = b2[(a[i] + 1ll * d) % p2];
		ans = max(ans,x + y);
		x = a4[a[i] % p4],y = b4[(a[i] + 2ll * d) % p4];
		ans = max(ans,x + y);
	}
	for(int i = 1;i <= m;i ++) {
		LL p2 = 2ll * d;
		LL p4 = 4ll * d;
		LL x = b2[b[i] % p2],y = a2[(b[i] + 1ll * d) % p2];
		ans = max(ans,x + y);
		x = b4[b[i] % p4],y = a4[(b[i] + 2ll * d) % p4];
		ans = max(ans,x + y);
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
const int SZ = 200010;
const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const LD eps = 1e-8;

LL read() {
    LL n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a <= '9' && a >= '0') { n = n * 10 + a - '0',a = getchar(); }
	if(flag) n = -n;
	return n;
}

LL n,m,a[SZ],b[SZ];
map<LL,LL> A[33],B[33];

int main() {
	int n = read(),y1 = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	int m = read(),y2 = read();
	for(int i = 1;i <= m;i ++) b[i] = read();
	LL d = 1;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			A[j][a[i] % ((1 << j) * d)] ++;
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			B[j][b[i] % ((1 << j) * d)] ++;
	}
	LL ans = 0;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,A[j][a[i] % p] + B[j][(a[i] + p / 2) % p]);
		}
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,B[j][b[i] % p] + A[j][(b[i] + p / 2) % p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
const int SZ = 200010;
const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const LD eps = 1e-8;

LL read() {
    LL n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a <= '9' && a >= '0') { n = n * 10 + a - '0',a = getchar(); }
	if(flag) n = -n;
	return n;
}

LL n,m,a[SZ],b[SZ];
unordered_map<LL,LL> A[33],B[33];

int main() {
	int n = read(),y1 = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	int m = read(),y2 = read();
	for(int i = 1;i <= m;i ++) b[i] = read();
	LL d = 1;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			A[j][a[i] % ((1 << j) * d)] ++;
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			B[j][b[i] % ((1 << j) * d)] ++;
	}
	LL ans = 0;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,A[j][a[i] % p] + B[j][(a[i] + p / 2) % p]);
		}
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,B[j][b[i] % p] + A[j][(b[i] + p / 2) % p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
const int SZ = 200010;
const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const LD eps = 1e-8;

LL read() {
    LL n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a <= '9' && a >= '0') { n = n * 10 + a - '0',a = getchar(); }
	if(flag) n = -n;
	return n;
}

LL n,m,a[SZ],b[SZ];
unordered_map<LL,LL> A[33],B[33];

int main() {
	int n = read(),y1 = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	int m = read(),y2 = read();
	for(int i = 1;i <= m;i ++) b[i] = read();
	LL d = 1;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			A[j][a[i] % ((1 << j) * d)] ++;
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			B[j][b[i] % ((1 << j) * d)] ++;
	}
	LL ans = 2;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,A[j][a[i] % p] + B[j][(a[i] + p / 2) % p]);
		}
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,B[j][b[i] % p] + A[j][(b[i] + p / 2) % p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
const int SZ = 200010;
const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const LD eps = 1e-8;

LL read() {
    LL n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a <= '9' && a >= '0') { n = n * 10 + a - '0',a = getchar(); }
	if(flag) n = -n;
	return n;
}

LL n,m,a[SZ],b[SZ];
map<LL,LL> A[33],B[33];

int main() {
	int n = read(),y1 = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	int m = read(),y2 = read();
	for(int i = 1;i <= m;i ++) b[i] = read();
	LL d = y2 - y1;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			A[j][a[i] % ((1 << j) * d)] ++;
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			B[j][b[i] % ((1 << j) * d)] ++;
	}
	LL ans = 0;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,A[j][a[i] % p] + B[j][(a[i] + p / 2) % p]);
		}
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,B[j][b[i] % p] + A[j][(b[i] + p / 2) % p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
const int SZ = 200010;
const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const LD eps = 1e-8;

LL read() {
    LL n = 0;
    char a = getchar();
    bool flag = 0;
    while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
    while(a <= '9' && a >= '0') { n = n * 10 + a - '0',a = getchar(); }
	if(flag) n = -n;
	return n;
}

int n,m,a[SZ],b[SZ];
map<LL,LL> A[33],B[33];

int main() {
	int n = read(),y1 = read();
	for(int i = 1;i <= n;i ++) a[i] = read();
	int m = read(),y2 = read();
	for(int i = 1;i <= m;i ++) b[i] = read();
	int d = y2 - y1;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			A[j][a[i] % ((1 << j) * d)] ++;
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++)
			B[j][b[i] % ((1 << j) * d)] ++;
	}
	LL ans = 0;
	for(int i = 1;i <= n;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,A[j][a[i] % p] + B[j][(a[i] + p / 2) % p]);
		}
	}
	for(int i = 1;i <= m;i ++) {
		for(LL j = 1;(1 << j) <= 1e9;j ++) {
			LL p = (1 << j) * d;
			ans = max(ans,B[j][b[i] % p] + A[j][(b[i] + p / 2) % p]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }

/*******************************************************/

int main() {
	int n; cin >> n;
	int y1; cin >> y1;
	vll a(n); Loop(i, n) cin >> a[i];
	int m; cin >> m;
	int y2; cin >> y2;
	vll b(m); Loop(i, m) cin >> b[i];
	int ans = 0;
	Loop(k, 31) {
		ll mod = (1LL << k) * 2;
		map<ll, int> mp;
		Loop(i, n) {
			mp[a[i] % mod]++;
		}
		Loop(i, m) {
			mp[(b[i] + mod / 2) % mod]++;
		}
		Loopitr(itr, mp) ans = max(ans, itr->second);
	}
	map<ll, int> mp;
	Loop(i, n) {
		mp[a[i]]++;
	}
	Loop(i, m) {
		mp[b[i]]++;
	}
	Loopitr(itr, mp) ans = max(ans, itr->second);
	cout << ans << endl;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }

/*******************************************************/

int main() {
	int n; cin >> n;
	int y1; cin >> y1;
	vll a(n); Loop(i, n) cin >> a[i];
	int m; cin >> m;
	int y2; cin >> y2;
	vll b(m); Loop(i, m) cin >> b[i];
	int ans = 0;
	Loop(k, 31) {
		ll mod = (1LL << k) * 2;
		map<ll, int> mp;
		Loop(i, n) {
			mp[a[i] % mod]++;
		}
		Loop(i, m) {
			mp[(b[i] + mod / 2) % mod]++;
		}
		Loopitr(itr, mp) ans = max(ans, itr->second);
	}
	cout << ans << endl;
}


#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }

/*******************************************************/

int main() {
	int n; cin >> n;
	int y1; cin >> y1;
	vll a(n); Loop(i, n) cin >> a[i];
	int m; cin >> m;
	int y2; cin >> y2;
	vll b(n); Loop(i, m) cin >> b[i];
	int ans = 0;
	Loop(k, 31) {
		ll mod = (1LL << k) * 2;
		map<ll, int> mp;
		Loop(i, n) {
			mp[a[i] % mod]++;
		}
		Loop(i, m) {
			mp[(b[i] + mod / 2) % mod]++;
		}
		Loopitr(itr, mp) ans = max(ans, itr->second);
	}
	cout << ans << endl;
}


// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld long double
#define sz(x) ((int) (x.size()))
#define all(x) x.begin(), x.end()
#define upper 1000000000000000000LL

#define max_n 1234567
#define mod 1000000007
#define myPrime 97654321

// #define x first
// #define y second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int n, m, t;
int a[123456];
int b[123456];
int A1[12236], A2[12236];

int main() {
	long long ST = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t;
	for(int i=0; i<n; i++) cin >> a[i];
	cin >> m >> t;
	for(int i=0; i<m; i++) cin >> b[i];
	int ans = 0;
	for(int l = 1; ; l++) {
		if( clock()-ST > 1.9 * CLOCKS_PER_SEC ) break;
		int B = l*2;
		int A1[B], A2[B];
		memset(A1, 0, sizeof A1);
		memset(A2, 0, sizeof A2);
		for(int i=0; i<n; i++) A1[a[i]%B]++;
		for(int i=0; i<m; i++) A2[b[i]%B]++;
		for(int i=0; i<B; i++) {
			int R1 = i;
			int R2 = (i+l)%B;
			ans = max(ans, A1[R1] + A2[R2]);
		}
	}
	// for(int lk = 1; ; lk++) {
	// 	if( clock()-ST > 1.9 * CLOCKS_PER_SEC ) break;
	// 	int l = (rand()%100)*10000 + (rand()%10000);
	// 	int B = l*2;
	// 	memset(A1, 0, sizeof A1);
	// 	memset(A2, 0, sizeof A2);
	// 	for(int i=0; i<n; i++) A1[a[i]%B]++;
	// 	for(int i=0; i<m; i++) A2[b[i]%B]++;
	// 	for(int i=0; i<B; i++) {
	// 		int R1 = i;
	// 		int R2 = (i+l)%B;
	// 		ans = max(ans, A1[R1] + A2[R2]);
	// 	}
	// }
	cout << ans << endl;
	return 0;
}


// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld long double
#define sz(x) ((int) (x.size()))
#define all(x) x.begin(), x.end()
#define upper 1000000000000000000LL

#define max_n 1234567
#define mod 1000000007
#define myPrime 97654321

// #define x first
// #define y second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int n, m, t;
int a[123456];
int b[123456];
map <int, int> mp1;
map <int, int> mp2;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t;
	for(int i=0; i<n; i++) cin >> a[i];
	cin >> m >> t;
	for(int i=0; i<m; i++) cin >> b[i];
	int ans = 0;
	for(int lk = 0; lk < 30; lk++) {
		int l = (1 << lk);
		int B = (l << 1);
		mp1.clear();
		mp2.clear();
		for(int i=0; i<n; i++) mp1[a[i]%B]++;
		for(int i=0; i<m; i++) mp2[b[i]%B]++;
		for(auto e : mp1) {
			int j = (e.first + l) % B;
			ans = max(ans, e.second + mp2[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld long double
#define sz(x) ((int) (x.size()))
#define all(x) x.begin(), x.end()
#define upper 1000000000000000000LL

#define max_n 1234567
#define mod 1000000007
#define myPrime 97654321

// #define x first
// #define y second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int n, m, t;
int a[123456];
int b[123456];
map <int, int> mp1;
map <int, int> mp2;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t;
	for(int i=0; i<n; i++) cin >> a[i];
	cin >> m >> t;
	for(int i=0; i<m; i++) cin >> b[i];
	int ans = 0;
	for(int lk = 0; lk < 30; lk++) {
		int l = (1 << lk);
		int B = (l << 1);
		mp1.clear();
		mp2.clear();
		for(int i=0; i<n; i++) mp1[a[i]%B]++;
		for(int i=0; i<m; i++) mp2[b[i]%B]++;
		for(auto e : mp1) {
			int j = (e.first + l) % B;
			ans = max(ans, e.second + mp2[j]);
		}
		for(auto e : mp2) {
			int j = (e.first + l) % B;
			ans = max(ans, e.second + mp1[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld long double
#define sz(x) ((int) (x.size()))
#define all(x) x.begin(), x.end()
#define upper 1000000000000000000LL

#define max_n 1234567
#define mod 1000000007
#define myPrime 97654321

// #define x first
// #define y second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int n, m, t;
int a[123456];
int b[123456];
int A1[1223116], A2[1211236];

int main() {
	long long ST = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t;
	for(int i=0; i<n; i++) cin >> a[i];
	cin >> m >> t;
	for(int i=0; i<m; i++) cin >> b[i];
	int ans = 0;
	for(int l = 1; ; l++) {
		if( clock()-ST > 1.1 * CLOCKS_PER_SEC ) break;
		int B = l*2;
		int A1[B], A2[B];
		memset(A1, 0, sizeof A1);
		memset(A2, 0, sizeof A2);
		for(int i=0; i<n; i++) A1[a[i]%B]++;
		for(int i=0; i<m; i++) A2[b[i]%B]++;
		for(int i=0; i<B; i++) {
			int R1 = i;
			int R2 = (i+l)%B;
			ans = max(ans, A1[R1] + A2[R2]);
		}
	}
	for(int lk = 1; ; lk++) {
		if( clock()-ST > 1.9 * CLOCKS_PER_SEC ) break;
		int l = (rand()%100)*10000 + (rand()%10000);
		int B = l*2;
		memset(A1, 0, sizeof A1);
		memset(A2, 0, sizeof A2);
		for(int i=0; i<n; i++) A1[a[i]%B]++;
		for(int i=0; i<m; i++) A2[b[i]%B]++;
		for(int i=0; i<B; i++) {
			int R1 = i;
			int R2 = (i+l)%B;
			ans = max(ans, A1[R1] + A2[R2]);
		}
	}
	cout << ans << endl;
	return 0;
}


// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld long double
#define sz(x) ((int) (x.size()))
#define all(x) x.begin(), x.end()
#define upper 1000000000000000000LL

#define max_n 1234567
#define mod 1000000007
#define myPrime 97654321

// #define x first
// #define y second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int n, m, t;
int a[123456];
int b[123456];
map <int, int> mp1;
map <int, int> mp2;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t;
	for(int i=0; i<n; i++) cin >> a[i];
	cin >> m >> t;
	for(int i=0; i<m; i++) cin >> b[i];
	int ans = (n>0)+(m>0);
	for(int lk = 0; lk < 30; lk++) {
		int l = (1 << lk);
		int B = (l << 1);
		mp1.clear();
		mp2.clear();
		for(int i=0; i<n; i++) mp1[a[i]%B]++;
		for(int i=0; i<m; i++) mp2[b[i]%B]++;
		for(auto e : mp1) {
			int j = (e.first + l) % B;
			ans = max(ans, e.second + mp2[j]);
		}
		for(auto e : mp2) {
			int j = (e.first + l) % B;
			ans = max(ans, e.second + mp1[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b);i>=(a);--i)
#define SIZE(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef long long ll;

template <class T> void mini(T& a, const T& b){a=min(a,b);}
template <class T> void maxi(T& a, const T& b){a=max(a,b);}

void solve(){
	int n,m,y;
	cin>>n>>y;
	vi a(n);
	REP(i,n) cin>>a[i];
	cin>>m>>y;
	vi b(m);
	REP(i,m) cin>>b[i];

	int ans = 1;

	unordered_set<int> sa(ALL(a));
	for (int x : b) if (sa.count(x)) {ans = 2; break;}

	FOR(k,1,31){
		const ll t = 1LL<<k;
		const ll mask = t - 1;
		unordered_map<int,int> ma, mb;
		for(int x : a) ma[x & mask]++;
		for(int x : b) mb[x & mask]++;

		for(auto const& p : ma) {
			int x = p.nd;
			int y = ((ll)p.st + t/2) & mask;
			if (mb.count(y)) x += mb[y];
			maxi(ans, x);
		}
		for(auto const& p : mb)
			maxi(ans, p.nd);
	}
	cout << ans << '\n';
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b);i>=(a);--i)
#define SIZE(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef long long ll;

template <class T> void mini(T& a, const T& b){a=min(a,b);}
template <class T> void maxi(T& a, const T& b){a=max(a,b);}

void solve(){
	int n,m,y;
	cin>>n>>y;
	vi a(n);
	REP(i,n) cin>>a[i];
	cin>>m>>y;
	vi b(m);
	REP(i,m) cin>>b[i];

	int ans = 0;
	FOR(k,1,32){
		const ll t = 1LL<<k;
		const ll mask = t - 1;
		unordered_map<int,int> ma, mb;
		for(int x : a) ma[x & mask]++;
		for(int x : b) mb[x & mask]++;

		for(auto const& p : ma) {
			int x = p.nd;
			int y = ((ll)p.st + t/2) & mask;
			if (mb.count(y)) x += mb[y];
			maxi(ans, x);
		}
		for(auto const& p : mb)
			maxi(ans, p.nd);
	}
	cout << ans << '\n';
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b);i>=(a);--i)
#define SIZE(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef long long ll;

template <class T> void mini(T& a, const T& b){a=min(a,b);}
template <class T> void maxi(T& a, const T& b){a=max(a,b);}

void solve(){
	int n,m,y;
	cin>>n>>y;
	vi a(n);
	REP(i,n) cin>>a[i];
	cin>>m>>y;
	vi b(m);
	REP(i,m) cin>>b[i];

	int ans = 0;
	FOR(k,1,31){
		const ll t = 1<<k;
		const ll mask = t - 1;
		unordered_map<int,int> ma, mb;
		for(int x : a) ma[x & mask]++;
		for(int x : b) mb[x & mask]++;

		for(auto const& p : ma) {
			int x = p.second;
			int y = (p.first + t/2) & mask;
			if (mb.count(y)) x += mb[y];
			maxi(ans, x);
		}
		for(auto const& p : mb)
			maxi(ans, p.second);
	}
	cout << ans << '\n';
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(b);i>=(a);--i)
#define SIZE(c) ((int)(c).size())
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef long long ll;

template <class T> void mini(T& a, const T& b){a=min(a,b);}
template <class T> void maxi(T& a, const T& b){a=max(a,b);}

void solve(){
	int n,m,y;
	cin>>n>>y;
	vi a(n);
	REP(i,n) cin>>a[i];
	cin>>m>>y;
	vi b(m);
	REP(i,m) cin>>b[i];

	int ans = 0;
	FOR(k,1,31){
		const ll t = 1LL<<k;
		const ll mask = t - 1;
		unordered_map<int,int> ma, mb;
		for(int x : a) ma[x & mask]++;
		for(int x : b) mb[x & mask]++;

		for(auto const& p : ma) {
			int x = p.nd;
			int y = ((ll)p.st + t/2) & mask;
			if (mb.count(y)) x += mb[y];
			maxi(ans, x);
		}
		for(auto const& p : mb)
			maxi(ans, p.nd);
	}
	cout << ans << '\n';
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


#include <bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,Y,ans;
vii v;
void solve(){
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        v.pb({y,0});
    }
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        v.pb({y,1});
    }
    int cur=1;
    rep(i,0,32){
        map<int,map<pii,int>> mp;
        for(auto j:v){
            mp[j.x%cur][{(j.x/cur)%2,j.y}]++;
        }
        for(auto j:mp){
            ans=max(ans,j.y[{0,0}]+j.y[{1,1}]);
            ans=max(ans,j.y[{1,0}]+j.y[{0,1}]);
        }
        cur*=2;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,Y,ans;
map<int,vii> mp[33];
void solve(){
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        int cur=1;
        rep(j,0,32){
            mp[j][y%cur].pb({(y/cur)%2,0});
            cur*=2;
        }
    }
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        int cur=1;
        rep(j,0,32){
            mp[j][y%cur].pb({(y/cur)%2,1});
            cur*=2;
        }
    }
    rep(i,0,32){
        for(auto j:mp[i]){
            int cnt[2][2]={};
            for(auto k:j.y){
                cnt[k.x][k.y]++;
            }
            ans=max(ans,cnt[0][0]+cnt[1][1]);
            ans=max(ans,cnt[0][1]+cnt[1][0]);
        }
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,Y,ans;
map<int,map<pii,int>> mp[33];
void solve(){
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        int cur=1;
        rep(j,0,31){
            mp[j][y%cur][{(y/cur)%2,0}]++;
            cur*=2;
        }
    }
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        int cur=1;
        rep(j,0,31){
            mp[j][y%cur][{(y/cur)%2,1}]++;
            cur*=2;
        }
    }
    rep(i,0,31){
        for(auto j:mp[i]){
            ans=max(ans,j.y[{0,0}]+j.y[{1,1}]);
            ans=max(ans,j.y[{1,0}]+j.y[{0,1}]);
        }
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,Y,ans;
vii v;
mi f;
void solve(){
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        v.pb({y,0});
        f[y]++;
    }
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        v.pb({y,1});
        f[y]++;
    }
    for(auto i:f) ans=max(ans,i.y);
    int cur=1;
    rep(i,0,31){
        map<int,map<pii,int>> mp;
        for(auto j:v){
            mp[j.x%cur][{(j.x/cur)%2,j.y}]++;
        }
        for(auto j:mp){
            ans=max(ans,j.y[{0,0}]+j.y[{1,1}]);
            ans=max(ans,j.y[{1,0}]+j.y[{0,1}]);
        }
        cur*=2;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,Y,ans;
mi mp[33][2][2];
void solve(){
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        int cur=1;
        rep(j,0,32){
            mp[j][(y/cur)%2][0][y%cur]++;
            cur*=2;
        }
    }
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        int cur=1;
        rep(j,0,32){
            mp[j][(y/cur)%2][1][y%cur]++;
            cur*=2;
        }
    }
    rep(i,0,32){
        ans=max(ans,sz(mp[i][0][0])+sz(mp[i][1][1]));
        ans=max(ans,sz(mp[i][0][1])+sz(mp[i][1][0]));
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,Y,ans;
vii v;
void solve(){
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        v.pb({y,0});
    }
    cin>>n>>Y;
    rep(i,0,n){
        int y;
        cin>>y;
        v.pb({y,1});
    }
    int cur=1;
    rep(i,0,31){
        map<int,map<pii,int>> mp;
        for(auto j:v){
            mp[j.x%cur][{(j.x/cur)%2,j.y}]++;
        }
        for(auto j:mp){
            ans=max(ans,j.y[{0,0}]+j.y[{1,1}]);
            ans=max(ans,j.y[{1,0}]+j.y[{0,1}]);
        }
        cur*=2;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,lg=31;
ll n,ys,yt,m,a[maxn],b[maxn],re;
map<ll,ll> mp[2][lg];
set<pair<ll,ll> > s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>ys;
    rep(i,0,n)
    {
        cin>>a[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(a[i]&(1<<j))
            {
                x^=(1<<j);
            }
            mp[0][j][x]++;
            //cout<<100<<endl;
            s.insert({x,j});
        }
    }
    cin>>m>>yt;
    rep(i,0,m)
    {
        cin>>b[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(b[i]&(1<<j));
            x^=(1<<j);
            mp[1][j][x]++;
            s.insert({x,j});
        }
    }
    for(auto u:s)
    {
        ll x=u.first,j=u.second;
        ll y=x^(1<<j);
        //cout<<x<<' '<<j<<' '<<y<<' '<<mp[0][j][x]<<' '<<mp[1][j][y]<<endl;
        re=max(re,mp[0][j][x]+mp[1][j][y]);
        re=max(re,mp[0][j][y]+mp[1][j][x]);
    }
    cout<<re;
    return 0;
}


//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,lg=30;
ll n,ys,yt,m,a[maxn],b[maxn],re;
map<ll,ll> mp[2][lg];
set<pair<ll,ll> > s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>ys;
    rep(i,0,n)
    {
        cin>>a[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(a[i]&(1<<j))
            {
                x^=(1<<j);
            }
            mp[0][j][x]++;
            //cout<<100<<endl;
            s.insert({x,j});
        }
    }
    cin>>m>>yt;
    rep(i,0,m)
    {
        cin>>b[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(b[i]&(1<<j));
            x^=(1<<j);
            mp[1][j][x]++;
        }
    }
    for(auto u:s)
    {
        ll x=u.first,j=u.second;
        ll y=x^(1<<j);
        //cout<<x<<' '<<j<<' '<<y<<' '<<mp[0][j][x]<<' '<<mp[1][j][y]<<endl;
        re=max(re,mp[0][j][x]+mp[1][j][y]);
    }
    cout<<re;
    return 0;
}


//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,lg=31;
ll n,ys,yt,m,a[maxn],b[maxn],re;
unordered_map<ll,ll> mp[2][lg],t;
set<pair<ll,ll> > s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>ys;
    rep(i,0,n)
    {
        cin>>a[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(a[i]&(1LL<<j))
            {
                x^=(1LL<<j);
            }
            mp[0][j][x]++;
            //cout<<100<<endl;
            s.insert({x,j});
        }
        t[a[i]]++;
    }
    cin>>m>>yt;
    rep(i,0,m)
    {
        cin>>b[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(b[i]&(1LL<<j))x^=(1LL<<j);
            mp[1][j][x]++;
            s.insert({x,j});
        }
        if(t[b[i]]>0)
        {
            re=2;
        }
    }
    for(auto u:s)
    {
        ll x=u.first,j=u.second;
        ll y=x^(1LL<<j);
        //cout<<x<<' '<<j<<' '<<y<<' '<<mp[0][j][x]<<' '<<mp[1][j][y]<<endl;
        //cout<<re<<endl;
        re=max(re,mp[0][j][x]+mp[1][j][y]);
        re=max(re,mp[0][j][y]+mp[1][j][x]);
    }
    cout<<re;
    return 0;
}


//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,lg=31;
ll n,ys,yt,m,a[maxn],b[maxn],re;
map<ll,ll> mp[2][lg],t;
set<pair<ll,ll> > s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>ys;
    rep(i,0,n)
    {
        cin>>a[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(a[i]&(1LL<<j))
            {
                x^=(1LL<<j);
            }
            mp[0][j][x]++;
            //cout<<100<<endl;
            s.insert({x,j});
        }
        t[a[i]]++;
    }
    cin>>m>>yt;
    rep(i,0,m)
    {
        cin>>b[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(b[i]&(1LL<<j))x^=(1LL<<j);
            mp[1][j][x]++;
            s.insert({x,j});
        }
        if(t[b[i]]>0)
        {
            re=2;
        }
    }
    for(auto u:s)
    {
        ll x=u.first,j=u.second;
        ll y=x^(1LL<<j);
        //cout<<x<<' '<<j<<' '<<y<<' '<<mp[0][j][x]<<' '<<mp[1][j][y]<<endl;
        //cout<<re<<endl;
        re=max(re,mp[0][j][x]+mp[1][j][y]);
        re=max(re,mp[0][j][y]+mp[1][j][x]);
    }
    cout<<re;
    return 0;
}


//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,lg=31;
ll n,ys,yt,m,a[maxn],b[maxn],re;
unordered_map<ll,ll> mp[2],t;
set<int> s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>ys;
    rep(i,0,n)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    cin>>m>>yt;
    rep(i,0,m)
    {
        cin>>b[i];
        if(s.find(b[i])!=s.end())re=2;
    }
    rep(j,1,lg+1)
    {
        mp[0].clear();
        mp[1].clear();
        rep(i,0,n)
        {
            mp[0][a[i]%(1<<j)]++;
            re=max(re,mp[0][a[i]%(1<<j)]);
        }
        rep(i,0,m)
        {
            mp[1][b[i]%(1<<j)]++;
            re=max(re,mp[1][b[i]%(1<<j)]+mp[0][(b[i]%(1<<j))^(1<<(j-1))]);
        }
    }
    cout<<re;
    return 0;
}


//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =1e5+5,lg=31;
ll n,ys,yt,m,a[maxn],b[maxn],re;
map<ll,ll> mp[2][lg],t;
set<pair<ll,ll> > s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>ys;
    rep(i,0,n)
    {
        cin>>a[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(a[i]&(1LL<<j))
            {
                x^=(1LL<<j);
            }
            mp[0][j][x]++;
            //cout<<100<<endl;
            s.insert({x,j});
        }
        t[a[i]]++;
    }
    cin>>m>>yt;
    rep(i,0,m)
    {
        cin>>b[i];
        ll x=0;
        rep(j,0,lg)
        {
            if(b[i]&(1LL<<j))x^=(1LL<<j);
            mp[1][j][x]++;
            s.insert({x,j});
        }
        if(t[b[i]]>0)
        {
            re=2;
        }
    }
    for(auto u:s)
    {
        ll x=u.first,j=u.second;
        ll y=x^(1LL<<j);
        //cout<<x<<' '<<j<<' '<<y<<' '<<mp[0][j][x]<<' '<<mp[1][j][y]<<endl;
        //cout<<re<<endl;
        re=max(re,mp[0][j][x]+mp[1][j][y]);
        re=max(re,mp[0][j][y]+mp[1][j][x]);
    }
    cout<<re;
    return 0;
}


#include "bits/stdc++.h"
#define int long long int
using namespace std;
vector<int> x,y,k;
signed main(){
    int n,m,h,o;
    cin >> n >> h;
    int mx = 0,mn=INT_MAX;
    while(n--){
        cin >> o;
        x.push_back(o);
        mx = max(o,mx);
        mn = min(o,mn);
    }
    cin >> m >> h;
    while(m--){
        cin >> o;
        y.push_back(o);
        mx = max(o,mx);
        mn = min(o,mn);
    }
    mx-=mn;
    int ans = 2;
    for(int i = 2; i/2*ans <= mx;i*=2){
        k.resize(i);
        for(int j:x){
            k[j%i]++;
        }
        for(int j:y){
            k[(j+i/2)%i]++;
        }
        for(auto j:k){
            ans = max(ans,j);
        }
        k.clear();
    }
    cout << ans << endl;
}


#include "bits/stdc++.h"
#define int long long int
using namespace std;
int x[4]={},y[4]={};
set<int> nn;
signed main(){
    int n,m,h,o;
    cin >> n >> h;
    while(n--){
        cin >> o;
        x[o%4]++;
    }
    cin >> m >> h;
    while(m--){
        cin >> o;
        y[o%4]++;

    }
    int ans = 2;
    ans = max(ans,x[0]+y[2]);
    ans = max(ans,x[1]+y[3]);
    ans = max(ans,x[2]+y[0]);
    ans = max(ans,x[3]+y[1]);
    ans = max(ans,x[0]+y[1]+x[2]+y[3]);
    ans = max(ans,x[1]+y[2]+x[3]+y[0]);
    cout << ans << endl;

}


#include "bits/stdc++.h"
#define int long long int
using namespace std;
int x[4]={},y[4]={};
signed main(){
    int n,m,h,o;
    cin >> n >> h;
    while(n--){
        cin >> o;
        x[(o%4+4)%4]++;
    }
    cin >> m >> h;
    while(m--){
        cin >> o;
        y[(o%4+4)%4]++;
    }
    int ans = 0;
    ans = max(ans,x[0]+y[2]);
    ans = max(ans,x[1]+y[3]);
    ans = max(ans,x[2]+y[0]);
    ans = max(ans,x[3]+y[1]);
    ans = max(ans,x[0]+y[1]+x[2]+y[3]);
    ans = max(ans,x[1]+y[2]+x[3]+y[0]);
    cout << ans << endl;

}


#include "bits/stdc++.h"
#define int long long int
using namespace std;
vector<int> x,y;
map<int,int>k;
signed main(){
    int n,m,h,o;
    cin >> n >> h;
    int mx = 0,mn=INT_MAX;
    while(n--){
        cin >> o;
        x.push_back(o);
        mx = max(o,mx);
        mn = min(o,mn);
    }
    cin >> m >> h;
    while(m--){
        cin >> o;
        y.push_back(o);
        mx = max(o,mx);
        mn = min(o,mn);
    }
    mx-=mn;
    int ans = 2;
    for(int i = 2; i/2*ans <= mx;i*=2){
        for(int j:x){
            k[j%i]++;
        }
        for(int j:y){
            k[(j+i/2)%i]++;
        }
        for(auto j:k){
            ans = max(ans,j.second);
        }
        k.clear();
    }
    cout << ans << endl;
}


#include "bits/stdc++.h"
#define int long long int
using namespace std;
vector<int> x,y,k;
signed main(){
    int n,m,h,o;
    cin >> n >> h;
    int mx = 0;
    while(n--){
        cin >> o;
        x.push_back(o);
        mx = max(o,mx);
    }
    cin >> m >> h;
    while(m--){
        cin >> o;
        y.push_back(o);
        mx = max(o,mx);
    }
    int ans = 2;
    for(int i = 2; i/2*ans <= mx;i*=2){
        k.resize(i);
        for(int j:x){
            k[j%i]++;
        }
        for(int j:y){
            k[(j+i/2)%i]++;
        }
        for(auto j:k){
            ans = max(ans,j);
        }
        k.resize(0);
    }
    cout << ans << endl;
}


#include "bits/stdc++.h"
#define int long long int

using namespace std;
int x[4]={},y[4]={};
signed main(){
    int n,m,h,o;
    cin >> n >> h;
    while(n--){
        cin >> o;
        x[o%4]++;
    }
    cin >> m >> h;
    while(m--){
        cin >> o;
        y[o%4]++;
    }
    int ans = 0;
    ans = max(ans,x[0]+y[2]);
    ans = max(ans,x[1]+y[3]);
    ans = max(ans,x[2]+y[0]);
    ans = max(ans,x[3]+y[1]);
    ans = max(ans,x[0]+y[1]+x[2]+y[3]);
    ans = max(ans,x[1]+y[2]+x[3]+y[0]);
    cout << ans << endl;

}


#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

enum condition{up, down};

struct para
{
    int x;
    condition cond;
    para(){}
    para(int val, condition cond)
        :x(val), cond(cond){}
};

bool cmp1(para right, para left)
{
    return right.x < left.x;
}

int main()
{
    int n;
    vector<para> a;
    scanf("%d%*d", &n);
    for(int i = 0; i < n; i++)
    {
        int c;
        scanf("%d", &c);
        a.push_back(para(c, down));
    }
    int m;
    scanf("%d%*d", &m);
    for(int i = 0; i < m; i++)
    {
        int c;
        scanf("%d", &c);
        a.push_back(para(c, up));
    }
    sort(a.begin(), a.end(), cmp1);

    map<int, int> down_sum, up_sum;

    int answer = 0;

    for(int half_step = 1; half_step < 1e9; half_step *= 2)
    {
        int step = half_step * 2;
        for(int i = 0; i < a.size(); i++)
        {
            int mod = a[i].x % step;
            if(a[i].cond == up)
            {
                int down_mod = ((mod - half_step) + step)% step;
                if(down_sum.find(down_mod) != down_sum.end())
                    up_sum[mod] = down_sum[down_mod] + 1;
                else if(up_sum.find(mod) != up_sum.end())
                    up_sum[mod]++;
                else
                    up_sum[mod] = 1;
            }
            else
            {
                int up_mod = ((mod - half_step) + step) % step;
                if(up_sum.find(up_mod) != up_sum.end())
                    down_sum[mod] = up_sum[up_mod] + 1;
                else if(down_sum.find(mod) != down_sum.end())
                    down_sum[mod]++;
                else
                    down_sum[mod] = 1;
            }
        }
        for(auto it : down_sum)
                if(it.second > answer)
                    answer = it.second;
        for(auto it : up_sum)
            if(it.second > answer)
                answer = it.second;
        down_sum.clear();
        up_sum.clear();
    }
    printf("%d", answer);
    return 0;
}


#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

enum condition{up, down};

struct para
{
    int x;
    condition cond;
    para(){}
    para(int val, condition cond)
        :x(val), cond(cond){}
};

bool cmp1(para right, para left)
{
    return right.x < left.x;
}

int main()
{
    int n;
    vector<para> a;
    scanf("%d%*d", &n);
    for(int i = 0; i < n; i++)
    {
        int c;
        scanf("%d", &c);
        a.push_back(para(c, down));
    }
    int m;
    scanf("%d%*d", &m);
    for(int i = 0; i < m; i++)
    {
        int c;
        scanf("%d", &c);
        a.push_back(para(c, up));
    }
    sort(a.begin(), a.end(), cmp1);

    map<int, int> down_sum, up_sum;

    int answer = 0, period;
    for(int half_step = 1; half_step < 1e9; half_step *= 2)
    {
        int step = half_step * 2;
        for(int i = 0; i < a.size(); i++)
        {
            int mod = a[i].x % step;
            if(a[i].cond == up)
            {
                int down_mod = ((mod - half_step) + step)% step;
                up_sum[mod]++;
                if(down_sum.find(down_mod) != down_sum.end())
                    up_sum[mod] = max(up_sum[mod], down_sum[down_mod] + 1);
            }
            else
            {
                int up_mod = ((mod - half_step) + step) % step;
                down_sum[mod]++;
                if(up_sum.find(up_mod) != up_sum.end())
                    down_sum[mod] = max(down_sum[mod], up_sum[up_mod] + 1);
            }
        }
        for(auto it : down_sum)
                if(it.second > answer)
                {
                    answer = it.second;
                    period = half_step;
                }
        for(auto it : up_sum)
            if(it.second > answer)
                {
                    answer = it.second;
                    period = half_step;
                }
        down_sum.clear();
        up_sum.clear();
    }
    if(n > 0 && m > 0 && answer == 1)
        answer = 2;
    printf("%d", answer);
    return 0;
}


#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

enum condition{up, down};

struct para
{
    int x;
    condition cond;
    para(){}
    para(int val, condition cond)
        :x(val), cond(cond){}
};

bool cmp1(para right, para left)
{
    return right.x < left.x;
}

int main()
{
    int n;
    vector<para> a;
    scanf("%d%*d", &n);
    for(int i = 0; i < n; i++)
    {
        int c;
        scanf("%d", &c);
        a.push_back(para(c, down));
    }
    int m;
    scanf("%d%*d", &m);
    for(int i = 0; i < m; i++)
    {
        int c;
        scanf("%d", &c);
        a.push_back(para(c, up));
    }
    sort(a.begin(), a.end(), cmp1);

    map<int, int> down_sum, up_sum;

    int answer = 0, period;
    for(int half_step = 1; half_step < 1e9; half_step *= 2)
    {
        int step = half_step * 2;
        for(int i = 0; i < a.size(); i++)
        {
            int mod = a[i].x % step;
            if(a[i].cond == up)
            {
                int down_mod = ((mod - half_step) + step)% step;
                up_sum[mod]++;
                if(down_sum.find(down_mod) != down_sum.end())
                    up_sum[mod] = max(up_sum[mod], down_sum[down_mod] + 1);
            }
            else
            {
                int up_mod = ((mod - half_step) + step) % step;
                down_sum[mod]++;
                if(up_sum.find(up_mod) != up_sum.end())
                    down_sum[mod] = max(down_sum[mod], up_sum[up_mod] + 1);
            }
        }
        for(auto it : down_sum)
                if(it.second > answer)
                {
                    answer = it.second;
                    period = half_step;
                }
        for(auto it : up_sum)
            if(it.second > answer)
                {
                    answer = it.second;
                    period = half_step;
                }
        down_sum.clear();
        up_sum.clear();
    }
    printf("%d", answer);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, y1;
    cin >> n >> y1;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int m, y2;
    cin >> m >> y2;
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    //
    // D := |A-B| = 2^k
    // D = 2    max(a0+b1, a1+b0)       if (a0>=a1 and b0<=b1) or (a0<=a1 and b0>=b1)
    // D = 4    max(a00+b10, a10+b00)   if a0>a1 and b0>b1
    //          max(a01+b11, a11+b01)   if a0<a1 and b0<b1
    //
    int ans = 0;
    while (true) {
        int cnt_a[2] = {}, cnt_b[2] = {};
        for (auto x : a) {
            cnt_a[abs(x) % 2] += 1;
        }
        for (auto x : b) {
            cnt_b[abs(x) % 2] += 1;
        }
        ans = max(max(ans, cnt_a[0] + cnt_b[1]), cnt_a[1] + cnt_b[0]);
        if ((cnt_a[0] >= cnt_a[1] && cnt_b[0] <= cnt_b[1]) || (cnt_a[0] <= cnt_a[1] && cnt_b[0] >= cnt_b[1])) {
            break;
        }
        if (a.size() == 1 && b.size() == 1 && a[0] == 0 && b[0] == 0) {
            ans = max(ans, 2);
            break;
        }
        int r = (cnt_a[0] > cnt_a[1])? 0 : 1;
        vector<int> aa, bb;
        for (auto x : a) {
            if (abs(x) % 2 == r) {
                aa.push_back((x-r)/2);
            }
        }
        for (auto x : b) {
            if (abs(x) % 2 == r) {
                bb.push_back((x-r)/2);
            }
        }
        swap(a, aa);
        swap(b, bb);
    }
    cout << ans << endl;

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, y1;
    cin >> n >> y1;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int m, y2;
    cin >> m >> y2;
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    //
    // D := |A-B| = 2^k
    // D = 2    max(a0+b1, a1+b0)       if (a0>=a1 and b0<=b1) or (a0<=a1 and b0>=b1)
    // D = 4    max(a00+b10, a10+b00)   if a0>a1 and b0>b1
    //          max(a01+b11, a11+b01)   if a0<a1 and b0<b1
    //
    int ans = 0;
    while (true) {
        int cnt_a[2] = {}, cnt_b[2] = {};
        for (auto x : a) {
            cnt_a[abs(x) % 2] += 1;
        }
        for (auto x : b) {
            cnt_b[abs(x) % 2] += 1;
        }
        ans = max(max(ans, cnt_a[0] + cnt_b[1]), cnt_a[1] + cnt_b[0]);
        if ((cnt_a[0] >= cnt_a[1] && cnt_b[0] <= cnt_b[1]) || (cnt_a[0] <= cnt_a[1] && cnt_b[0] >= cnt_b[1])) {
            break;
        }
        if (a.size() == 1 && b.size() == 1 && a[0] == 0 && b[0] == 0) {
            break;
        }
        int r = (cnt_a[0] > cnt_a[1])? 0 : 1;
        vector<int> aa, bb;
        for (auto x : a) {
            if (abs(x) % 2 == r) {
                aa.push_back((x-r)/2);
            }
        }
        for (auto x : b) {
            if (abs(x) % 2 == r) {
                bb.push_back((x-r)/2);
            }
        }
        swap(a, aa);
        swap(b, bb);
    }
    cout << ans << endl;

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, y1;
    cin >> n >> y1;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int m, y2;
    cin >> m >> y2;
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    //
    // D := |A-B| = 2^k
    // D = 2    max(a0+b1, a1+b0)       if (a0>=a1 and b0<=b1) or (a0<=a1 and b0>=b1)
    // D = 4    max(a00+b10, a10+b00)   if a0>a1 and b0>b1
    //          max(a01+b11, a11+b01)   if a0<a1 and b0<b1
    //
    int ans = 0;
    while (true) {
        int cnt_a[2] = {}, cnt_b[2] = {};
        for (auto x : a) {
            cnt_a[abs(x) % 2] += 1;
        }
        for (auto x : b) {
            cnt_b[abs(x) % 2] += 1;
        }
        ans = max(max(ans, cnt_a[0] + cnt_b[1]), cnt_a[1] + cnt_b[0]);
        if ((cnt_a[0] >= cnt_a[1] && cnt_b[0] <= cnt_b[1]) || (cnt_a[0] <= cnt_a[1] && cnt_b[0] >= cnt_b[1])) {
            break;
        }
        int r = (cnt_a[0] > cnt_a[1])? 0 : 1;
        vector<int> aa, bb;
        for (auto x : a) {
            if (abs(x) % 2 == r) {
                aa.push_back((x-r)/2);
            }
        }
        for (auto x : b) {
            if (abs(x) % 2 == r) {
                bb.push_back((x-r)/2);
            }
        }
        swap(a, aa);
        swap(b, bb);
    }
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int LOG = 30;
const int MAXN = 1E5;
int a[MAXN];
int b[MAXN];
map<int, int> mp1[LOG + 1];
map<int, int> mp2[LOG + 1];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, y1;
    cin >> n >> y1;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int m, y2;
    cin >> m >> y2;
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int i = 1; i <= LOG; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int mod = a[j] & ((1 << i) - 1);
            if (mp1[i].count(mod))
                mp1[i][mod]++;
            else
                mp1[i][mod] = 1;
        }
        for (int j = 0; j < m; j++)
        {
            int mod = b[j] & ((1 << i) - 1);
            if (mp2[i].count(mod))
                mp2[i][mod]++;
            else
                mp2[i][mod] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= LOG; j++)
        {
            int mod = a[i] & ((1 << j) - 1);
            int mod2 = (mod + (1 << (j - 1))) & ((1 << j) - 1);
            ans = max(ans, mp1[j][mod] + (mp2[j].count(mod2) ? mp2[j][mod2] : 0));
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 1; j <= LOG; j++)
        {
            int mod = b[i] & ((1 << j) - 1);
            int mod2 = (mod + (1 << (j - 1))) & ((1 << j) - 1);
            ans = max(ans, mp2[j][mod] + (mp1[j].count(mod2) ? mp1[j][mod2] : 0));
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int LOG = 30;
const int MAXN = 1E5;
int a[MAXN];
int b[MAXN];
map<int, int> mp1[LOG + 1];
map<int, int> mp2[LOG + 1];

int main()
{
    int n, y1;
    cin >> n >> y1;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int m, y2;
    cin >> m >> y2;
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int i = 1; i <= LOG; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int mod = a[j] & ((1 << i) - 1);
            if (mp1[i].count(mod))
                mp1[i][mod]++;
            else
                mp1[i][mod] = 1;
        }
        for (int j = 0; j < m; j++)
        {
            int mod = b[j] & ((1 << i) - 1);
            if (mp2[i].count(mod))
                mp2[i][mod]++;
            else
                mp2[i][mod] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= LOG; j++)
        {
            int mod = a[i] & ((1 << j) - 1);
            int mod2 = (mod + (1 << (j - 1))) & ((1 << j) - 1);
            ans = max(ans, mp1[j][mod] + (mp2[j].count(mod2) ? mp2[j][mod2] : 0));
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 1; j <= LOG; j++)
        {
            int mod = b[i] & ((1 << j) - 1);
            int mod2 = (mod + (1 << (j - 1))) & ((1 << j) - 1);
            ans = max(ans, mp2[j][mod] + (mp1[j].count(mod2) ? mp1[j][mod2] : 0));
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int LOG = 30;
const int MAXN = 1E5;
int a[MAXN];
int b[MAXN];
map<int, int> mp1[LOG + 1];
map<int, int> mp2[LOG + 1];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, y1;
    cin >> n >> y1;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int m, y2;
    cin >> m >> y2;
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int i = 1; i <= LOG; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int mod = a[j] & ((1 << i) - 1);
            if (mp1[i].count(mod))
                mp1[i][mod]++;
            else
                mp1[i][mod] = 1;
        }
        for (int j = 0; j < m; j++)
        {
            int mod = b[j] & ((1 << i) - 1);
            if (mp2[i].count(mod))
                mp2[i][mod]++;
            else
                mp2[i][mod] = 1;
        }
    }
    int ans = 1;
    int ptr = 0;
    for (int i = 0; i < n; i++)
    {
        while (ptr < m && b[ptr] < a[i])
            ptr++;
        if (a[i] == b[ptr])
            ans = 2;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j <= LOG; j++)
        {
            int mod = a[i] & ((1 << j) - 1);
            int mod2 = (mod + (1 << (j - 1))) & ((1 << j) - 1);
            ans = max(ans, mp1[j][mod] + (mp2[j].count(mod2) ? mp2[j][mod2] : 0));
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 1; j <= LOG; j++)
        {
            int mod = b[i] & ((1 << j) - 1);
            int mod2 = (mod + (1 << (j - 1))) & ((1 << j) - 1);
            ans = max(ans, mp2[j][mod] + (mp1[j].count(mod2) ? mp1[j][mod2] : 0));
        }
    }
    cout << ans << endl;
    return 0;
}


#include<algorithm>
#include<cstdio>
#include<vector>

#define MAXN 100005

int n, m, y1, y2;
int a[MAXN];
int b[MAXN];

int best_for_k(int k) {
    //printf("\n\nCalculating for %d\n", k);
    std::vector<int> a_res;
    std::vector<int> b_res;
    for (int i = 0; i<n; i++) {
        a_res.push_back(a[i] % (2*k));
    }
    for (int i = 0; i<m; i++) {
        b_res.push_back((b[i] + k) % (2*k));
    }
    std::sort(a_res.begin(), a_res.end());
    //for(int i = 0; i<n; i++) {
    //    printf("%d ", a_res[i]);
    //}
    //printf("\n");
    std::sort(b_res.begin(), b_res.end());
    //for(int i = 0; i<m; i++) {
    //    printf("%d ", b_res[i]);
    //}
    //printf("\n");
    int best = 0;
    int a_idx = 0;
    int b_idx = 0;
    while (a_idx < n || b_idx < m) {
        int residue = -1;
        if (a_idx < n) {
            if (residue < 0 || a_res[a_idx] < residue) {
                residue = a_res[a_idx];
            }
        }
        if (b_idx < m) {
            if (residue < 0 || b_res[b_idx] < residue) {
                residue = b_res[b_idx];
            }
        }
        int count = 0;
        while (a_idx < n && a_res[a_idx] == residue) {
            a_idx++;
            count++;
        }
        while (b_idx < m && b_res[b_idx] == residue) {
            b_idx++;
            count++;
        }
        if (count > best) {
            best = count;
        }
    }
    return best;
}

int main() {
    scanf("%d%d", &n, &y1);
    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]);
    }

    int best = 0;
    for (int k = 1; 2*k > 0; k *= 2) {
        int possibility = best_for_k(k);
        //printf("%d %d\n", k, possibility);
        if (possibility > best) {
            best = possibility;
        }
    }

    printf("%d\n", best);
}


#include<algorithm>
#include<cstdio>
#include<vector>

#define MAXN 100005

int n, m, y1, y2;
int a[MAXN];
int b[MAXN];

int best_for_k(int k) {
    //printf("\n\nCalculating for %d\n", k);
    std::vector<int> a_res;
    std::vector<int> b_res;
    for (int i = 0; i<n; i++) {
        a_res.push_back(a[i] % (2*k));
    }
    for (int i = 0; i<m; i++) {
        b_res.push_back((b[i] + k) % (2*k));
    }
    std::sort(a_res.begin(), a_res.end());
    //for(int i = 0; i<n; i++) {
    //    printf("%d ", a_res[i]);
    //}
    //printf("\n");
    std::sort(b_res.begin(), b_res.end());
    //for(int i = 0; i<m; i++) {
    //    printf("%d ", b_res[i]);
    //}
    //printf("\n");
    int best = 0;
    int a_idx = 0;
    int b_idx = 0;
    while (a_idx < n || b_idx < m) {
        int residue = -1;
        if (a_idx < n) {
            if (residue < 0 || a_res[a_idx] < residue) {
                residue = a_res[a_idx];
            }
        }
        if (b_idx < m) {
            if (residue < 0 || b_res[b_idx] < residue) {
                residue = b_res[b_idx];
            }
        }
        int count = 0;
        while (a_idx < n && a_res[a_idx] == residue) {
            a_idx++;
            count++;
        }
        while (b_idx < m && b_res[b_idx] == residue) {
            b_idx++;
            count++;
        }
        if (count > best) {
            best = count;
        }
    }
    return best;
}
int main() {
    scanf("%d%d", &n, &y1);
    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]);
    }

    int best = 0;
    for (int k = 1; k < 1073741824; k *= 2) {
        int possibility = best_for_k(k);
        //printf("%d %d\n", k, possibility);
        if (possibility > best) {
            best = possibility;
        }
    }

    printf("%d\n", best);
}


#include<algorithm>
#include<cstdio>
#include<vector>

#define MAXN 100005

int n, m, y1, y2;
int a[MAXN];
int b[MAXN];

int best_for_k(int k) {
    //printf("\n\nCalculating for %d\n", k);
    std::vector<int> a_res;
    std::vector<int> b_res;
    for (int i = 0; i<n; i++) {
        a_res.push_back(a[i] % (2*k));
    }
    for (int i = 0; i<m; i++) {
        b_res.push_back((b[i] + k) % (2*k));
    }
    std::sort(a_res.begin(), a_res.end());
    //for(int i = 0; i<n; i++) {
    //    printf("%d ", a_res[i]);
    //}
    //printf("\n");
    std::sort(b_res.begin(), b_res.end());
    //for(int i = 0; i<m; i++) {
    //    printf("%d ", b_res[i]);
    //}
    //printf("\n");
    int best = 0;
    int a_idx = 0;
    int b_idx = 0;
    while (a_idx < n || b_idx < m) {
        int residue = -1;
        if (a_idx < n) {
            if (residue < 0 || a_res[a_idx] < residue) {
                residue = a_res[a_idx];
            }
        }
        if (b_idx < m) {
            if (residue < 0 || b_res[b_idx] < residue) {
                residue = b_res[b_idx];
            }
        }
        int count = 0;
        while (a_idx < n && a_res[a_idx] == residue) {
            a_idx++;
            count++;
        }
        while (b_idx < m && b_res[b_idx] == residue) {
            b_idx++;
            count++;
        }
        if (count > best) {
            best = count;
        }
    }
    return best;
}
int main() {
    scanf("%d%d", &n, &y1);
    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]);
    }

    int best = 2;
    for (int k = 1; k < 1073741824; k *= 2) {
        int possibility = best_for_k(k);
        //printf("%d %d\n", k, possibility);
        if (possibility > best) {
            best = possibility;
        }
    }

    printf("%d\n", best);
}


#include <bits/stdc++.h>
#include <random>
#include <bitset>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define F first
#define S second
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define all(vec) vec.begin(), vec.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 2e6 + 10;
const int INF = 1LL << 60;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define RANDOM_GEN(st, ed)  uniform_int_distribution<int>(st, ed)(rng)

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve()
{
	int n, m;
	int y;
	cin >> n >> y;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	cin >> m >> y;
	vector<int> b(m);
	int ans = 0;
	for(int i=0; i<m; i++) cin >> b[i];
	for(int i=0; i<=30; i++){
		int d = (1 << i);
		d = d * 2;
		map<int,int> mp;
		for(int j=0; j<n; j++){
			mp[a[i]%d]++;
		}
		for(int j=0; j<m; j++){
			mp[(b[i]+d/2)%d]++;
		}
		int mx = 0;
		for(auto x: mp){
			chmax(mx, x.second);
		}
		chmax(ans, mx);
	}
	cout << ans << '\n';
}

signed main()
{
    FAST
    int Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
		//cout<<"Case #"<<(t++)<<": ";
        solve();
    }
    return 0;
}