#include <bits/stdc++.h>
using namespace std;
int main() {
  int markers[1005][1005] = {};
  int caps[1005][1005] = {};
  int x, y;
  int n;
  int m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    markers[x][y]++;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    caps[x][y]++;
  }
  int u = 0;
  int v = 0;
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      while (markers[i][j] && caps[i][j]) {
        markers[i][j]--;
        caps[i][j]--;
        u++;
        v++;
      }
    }
  }
  for (int i = 1; i <= 1000; i++) {
    int tot_m = 0;
    int tot_c = 0;
    for (int j = 0; j <= 1000; j++) {
      if (markers[j][i]) tot_m += markers[j][i];
      if (caps[j][i]) tot_c += caps[j][i];
    }
    u += min(tot_m, tot_c);
  }
  printf("%d %d\n", u, v);
  return 0;
}
