#include <bits/stdc++.h>
int a[1001][1001] = {0};
int main() {
  long int n, m, i, j, tm = 0, bm = 0;
  scanf("%ld %ld", &n, &m);
  int x[n], y[n], x1[m], y1[m], b[1001] = {0};
  int p, q;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &x[i], &y[i]);
    a[x[i]][y[i]]++;
    b[y[i]]++;
  }
  for (i = 0; i < m; i++) {
    scanf("%d %d", &x1[i], &y1[i]);
    if (a[x1[i]][y1[i]] > 0) {
      tm++;
      bm++;
      a[x1[i]][y1[i]]--;
      b[y1[i]]--;
      y1[i] = '\0';
    }
  }
  for (i = 0; i < m; i++) {
    if (y1[i] != '\0') {
      if (b[y1[i]] > 0) {
        tm++;
        b[y1[i]]--;
      }
    }
  }
  printf("%ld %ld", tm, bm);
  return 0;
}
