#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int pen[1001][1001] = {0}, cap[1001][1001] = {0};
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int c, d;
    cin >> c >> d;
    pen[c][d]++;
  }
  for (int i = 0; i < m; i++) {
    int c, d;
    cin >> c >> d;
    cap[c][d]++;
  }
  long long count = 0, count2;
  for (int i = 1; i < 1001; i++) {
    for (int j = 1; j < 1001; j++) {
      int k = min(cap[i][j], pen[i][j]);
      count += k;
      cap[i][j] -= k;
      pen[i][j] -= k;
    }
  }
  count2 = count;
  for (int i = 1; i < 1001; i++) {
    int pens = 0, caps = 0;
    for (int j = 1; j < 1001; j++) {
      pens += pen[j][i];
      caps += cap[j][i];
    }
    count2 += min(pens, caps);
  }
  cout << count2 << " " << count;
  return 0;
}
