#include #include using namespace std; int main(){ int N, M; cin >> N >> M; vector A(N), B(N), C(N); for (int i = 0; i < N; i++){ cin >> A[i] >> B[i] >> C[i]; } vector X(M), Y(M), Z(M); for (int i = 0; i < M; i++){ cin >> X[i] >> Y[i] >> Z[i]; } vector a(N); for (int i = 0; i < N; i++){ a[i] = A[i] * 10201 + B[i] * 101 + C[i]; } vector b(M); for (int i = 0; i < M; i++){ b[i] = X[i] * 10201 + Y[i] * 101 + Z[i]; } vector f(1030301, 0); for (int i = 0; i < N; i++){ f[a[i]]++; } vector g = f; reverse(g.begin(), g.end()); vector h = atcoder::convolution(f, g); int ans = 0; for (int i = 0; i < M; i++){ ans = max(ans, N * 2 - (int) h[1030300 + b[i]]); } cout << ans << endl; }