#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> pen[1002], cap[1002];
  int t1, t2;
  for (int i = (0); i < (n); i++) {
    cin >> t1 >> t2;
    pen[t2].push_back(t1);
  }
  for (int i = (1); i < (1001); i++) {
    sort(pen[i].begin(), pen[i].end());
  }
  for (int i = (0); i < (m); i++) {
    cin >> t1 >> t2;
    cap[t2].push_back(t1);
  }
  for (int i = (1); i < (1001); i++) {
    sort(cap[i].begin(), cap[i].end());
  }
  int clos = 0, beauti = 0;
  for (int i = (1); i < (1001); i++) {
    if (pen[i].size() != 0 && cap[i].size() != 0) {
      clos += min(pen[i].size(), cap[i].size());
      int st1 = 0, st2 = 0;
      while (st1 < pen[i].size() && st2 < cap[i].size()) {
        if (pen[i][st1] == cap[i][st2]) {
          st1++;
          st2++;
          beauti++;
        } else if (pen[i][st1] > cap[i][st2]) {
          st2++;
        } else
          st1++;
      }
    }
  }
  cout << clos << " " << beauti << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
