#include <bits/stdc++.h>
using namespace std;
int fl[1001][1001];
int kp[1001][1001];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    fl[b][a]++;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    kp[b][a]++;
  }
  int kol_kras = 0;
  int kol = 0;
  for (int i = 0; i < 1001; i++) {
    int kol_kp = 0;
    int kol_fl = 0;
    for (int j = 0; j < 1001; j++) {
      int a = min(fl[i][j], kp[i][j]);
      kol_kras += a;
      kol += a;
      fl[i][j] -= a;
      kp[i][j] -= a;
      kol_kp += kp[i][j];
      kol_fl += fl[i][j];
    }
    kol += min(kol_kp, kol_fl);
  }
  cout << kol << " " << kol_kras;
  return 0;
}
