#include <bits/stdc++.h>
using namespace std;
int main() {
  multiset<int> x[1001], y[1001];
  vector<set<int> > x1(1001);
  int n, m, t, l, r;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    x[r].insert(l);
    x1[r].insert(l);
  }
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    y[r].insert(l);
  }
  int BT = 0, NBT = 0;
  for (int i = 1; i < 1001; i++) {
    NBT += min(x[i].size(), y[i].size());
    if (x[i].size() != 0 && y[i].size() != 0) {
      set<int>::iterator it;
      for (it = x1[i].begin(); it != x1[i].end(); it++) {
        BT += min(x[i].count(*it), y[i].count(*it));
        x[i].erase(*it);
        y[i].erase(*it);
      }
    }
  }
  cout << NBT << " " << BT;
  return 0;
}
