#include <bits/stdc++.h>
using namespace std;
const int sz = 1001;
int fl[sz][sz], c[sz][sz];
int main() {
  int n, m, x, y, good = 0, all = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    fl[y][x]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    c[y][x]++;
  }
  for (int i = 0; i < sz; i++) {
    int p = 0, q = 0;
    for (int j = 0; j < sz; j++) {
      good += min(fl[i][j], c[i][j]);
      p += fl[i][j];
      q += c[i][j];
    }
    all += min(p, q);
  }
  cout << all << " " << good;
}
