#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> maker;
vector<pair<int, int>> cap;
bool cmp(pair<int, int>& a, pair<int, int>& b) {
  return a.second < b.second || (a.second == b.second && a.first < b.first);
}
int main() {
  int n, m, i, j, i2, j2, x;
  int c1 = 0, c2 = 0;
  cin >> n >> m;
  maker.resize(n);
  cap.resize(m);
  for (i = 0; i < n; i++) cin >> maker[i].first >> maker[i].second;
  sort(maker.begin(), maker.end(), cmp);
  for (j = 0; j < m; j++) cin >> cap[j].first >> cap[j].second;
  sort(cap.begin(), cap.end(), cmp);
  i = j = 0;
  while (j < n && i < m) {
    if (maker[j].second < cap[i].second)
      j++;
    else if (maker[j].second > cap[i].second)
      i++;
    else {
      i2 = j2 = 0;
      x = maker[j].second;
      while (i < m && j < n && maker[j].second == x && cap[i].second == x) {
        if (maker[j].first < cap[i].first) {
          j++;
          j2++;
        } else if (maker[j].first > cap[i].first) {
          i++;
          i2++;
        } else {
          c2++;
          i2++;
          j2++;
          i++;
          j++;
        }
      }
      while (j < n && maker[j].second == x) {
        j++;
        j2++;
      }
      while (i < m && cap[i].second == x) {
        i++;
        i2++;
      }
      c1 += min(i2, j2);
    }
  }
  cout << c1 << " " << c2 << endl;
  return 0;
}
