#include <bits/stdc++.h>
using namespace std;
int pen[1024][1024], n;
int cap[1024][1024], m;
int main() {
  int dia, col;
  cin >> n >> m;
  memset(pen, 0, sizeof pen);
  memset(cap, 0, sizeof cap);
  for (int i = 0; i < n; i++) {
    cin >> col >> dia;
    pen[dia][col]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> col >> dia;
    cap[dia][col]++;
  }
  int all, good;
  all = good = 0;
  for (int i = 1; i <= 1000; i++)
    for (int j = 1; j <= 1000; j++) {
      int mn = min(pen[i][j], cap[i][j]);
      good += mn;
      pen[i][j] -= mn;
      cap[i][j] -= mn;
    }
  all += good;
  for (int i = 1; i <= 1000; i++) {
    int row1 = 0;
    int row2 = 0;
    for (int j = 1; j <= 1000; j++) {
      row1 += pen[i][j];
      row2 += cap[i][j];
    }
    all += min(row1, row2);
  }
  cout << all << " " << good << endl;
  return 0;
}
