#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
const int C = 1000;
const int D = 1000;
using namespace std;
int main() {
  int clp[C][D];
  int f[C][D];
  int clp_sum[D];
  int f_sum[D];
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < D; j++) {
      clp[i][j] = 0;
      f[i][j] = 0;
    }
  }
  for (int i = 0; i < D; i++) {
    f_sum[i] = 0;
    clp_sum[i] = 0;
  }
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    f[x - 1][y - 1]++;
    f_sum[y - 1]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    clp[x - 1][y - 1]++;
    clp_sum[y - 1]++;
  }
  int k_kr = 0;
  int k_nek = 0;
  for (int c = 0; c < C; c++) {
    for (int d = 0; d < D; d++) {
      int cnt = min(f[c][d], clp[c][d]);
      k_kr += cnt;
      f_sum[d] -= cnt;
      clp_sum[d] -= cnt;
    }
  }
  for (int d = 0; d < D; d++) {
    int cnt = min(f_sum[d], clp_sum[d]);
    k_nek += cnt;
  }
  cout << k_kr + k_nek << ' ' << k_kr << endl;
  return 0;
}
