#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, x, y;
  map<pair<int, int>, int> t1;
  map<pair<int, int>, int> t2;
  map<int, int> v1;
  map<int, int> v2;
  int loula, thenya;
  cin >> n >> m;
  vector<pair<int, int> > v, u;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    v1[b]++;
    v.push_back(make_pair(a, b));
    t1[make_pair(a, b)]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    v2[y]++;
    u.push_back(make_pair(x, y));
    t2[make_pair(x, y)]++;
  }
  if (n < m) {
    loula = 0, thenya = 0;
    for (int i = 0; i < n; i++) {
      loula += min(v1[v[i].second], v2[v[i].second]);
      v1[v[i].second] = 0;
    }
    for (int i = 0; i < n; i++) {
      thenya += min(t1[v[i]], t2[v[i]]);
      t1[v[i]] = 0;
    }
  } else {
    loula = 0, thenya = 0;
    for (int i = 0; i < m; i++) {
      loula += min(v1[u[i].second], v2[u[i].second]);
      v1[u[i].second] = 0;
    }
    for (int i = 0; i < m; i++) {
      thenya += min(t1[u[i]], t2[u[i]]);
      t1[u[i]] = 0;
    }
  }
  cout << loula << " " << thenya;
}
