#include <bits/stdc++.h>
using namespace std;
int main() {
  map<pair<int, int>, int> markers;
  map<int, int> diadetails, diadetails2;
  map<int, int>::iterator it;
  int n, m, i, a, b, closed = 0, per = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    markers[make_pair(a, b)]++;
    diadetails[b]++;
  }
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    if (markers[make_pair(a, b)] != 0) {
      markers[make_pair(a, b)]--;
      diadetails[b]--;
      closed++;
      per++;
    } else {
      diadetails2[b]++;
    }
  }
  for (it = diadetails.begin(); it != diadetails.end(); it++) {
    closed += min(it->second, diadetails2[it->first]);
  }
  cout << closed << " " << per << endl;
  return 0;
}
