#include <bits/stdc++.h>
using namespace std;
const int MAXN = 101000, MAXT = 1100;
int a[MAXT][MAXT], b[MAXT][MAXT], asum[MAXT], bsum[MAXT];
int main() {
  int n, m, x, y, beauty = 0, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    a[y][x]++;
  }
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    b[y][x]++;
  }
  for (int i = 1; i < MAXT; i++)
    for (int j = 1; j < MAXT; j++) {
      asum[i] += a[i][j];
      bsum[i] += b[i][j];
    }
  for (int i = 1; i < MAXT; i++) {
    ans += min(asum[i], bsum[i]);
    for (int j = 1; j < MAXT; j++) {
      beauty += min(a[i][j], b[i][j]);
    }
  }
  cout << ans << " " << beauty;
  return 0;
}
