#include <bits/stdc++.h>
using namespace std;
int calc(map<int, int> &x, map<int, int> &y) {
  int ret = 0;
  for (auto pr : x) {
    ret += min(pr.second, y[pr.first]);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  map<int, int> v1, v2;
  for (int i = 0; i < (int)(n); i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    v1[y]++;
    v2[1000 * x + y]++;
  }
  map<int, int> w1, w2;
  for (int i = 0; i < (int)(m); i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    w1[b]++;
    w2[1000 * a + b]++;
  }
  cout << calc(v1, w1) << " " << calc(v2, w2) << endl;
  return 0;
}
