#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include using namespace std; typedef bitset<1030301> B; int main(){ int n, m; cin >> n >> m; vector a(n), b(n), c(n); vector x(m), y(m), z(m); B moto; for (int i=0; i> a[i] >> b[i] >> c[i]; moto[a[i] + b[i] * 101 + c[i] * 101 * 101] = 1; } int ans = 0; for (int i=0; i> x[i] >> y[i] >> z[i]; int t = x[i] + y[i] * 101 + z[i] * 101 * 101; if (t >= 0){ ans = max(ans, (int)(moto | (moto << t)).count()); }else{ ans = max(ans, (int)(moto | (moto >> -t)).count()); } } cout << ans << '\n'; }