#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, u, v;
  map<int, int> sizes, size;
  map<int, int> v1, v2;
  cin >> n >> m;
  while (n--) {
    cin >> u >> v;
    sizes[v]++;
    size[v] = 0;
    v1[u * 1000 + v]++;
    v2[u * 1000 + v] = 0;
  }
  while (m--) {
    cin >> u >> v;
    size[v]++;
    v2[u * 1000 + v]++;
  }
  u = v = 0;
  for (auto it = sizes.begin(); it != sizes.end(); it++) {
    u += min(it->second, size[it->first]);
  }
  for (auto it = v1.begin(); it != v1.end(); it++) {
    v += min(it->second, v2[it->first]);
  }
  cout << u << " " << v;
  return 0;
}
