#include #include using namespace std; using mint = atcoder::modint998244353; const int tot = 101*101*101; int colid(int a, int b, int c){ return a + b*101 + c*101*101; } int main(){ int n, m; cin >> n >> m; vector f(tot,0); for (int i = 0; i < n; i++){ int a, b, c; cin >> a >> b >> c; f[colid(a,b,c)] = 1; } auto g = f; reverse(g.begin(),g.end()); auto fg = atcoder::convolution(f,g); int ans = 0; for (int i = 0; i < m; i++){ int x, y, z; cin >> x >> y >> z; int d = colid(x,y,z); int sum = fg[tot-1+d].val(); ans = max(ans,n+n-sum); } cout << ans << endl; }