#include #include using namespace std; using mint = atcoder::modint998244353; const int mx = 110; // not 101 const int tot = mx*mx*mx; int colid(int a, int b, int c){ return a + b*mx + c*mx*mx; } 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; }