#include <bits/stdc++.h>
using namespace std;
int getint() {
  unsigned int c;
  int x = 0;
  while (((c = getchar()) - '0') >= 10) {
    if (c == '-') return -getint();
    if (!~c) exit(0);
  }
  do {
    x = (x << 3) + (x << 1) + (c - '0');
  } while (((c = getchar()) - '0') < 10);
  return x;
}
int n, m;
int color[100111], diameter[100111];
int fullCnt[1001][1001], diaCnt[1001];
int main() {
  int i, j, tcc, tc = 1 << 28, x, y;
  for (tcc = 0; tcc < tc; tcc++) {
    memset(fullCnt, 0, sizeof(fullCnt));
    memset(diaCnt, 0, sizeof(diaCnt));
    n = getint(), m = getint();
    for (i = 0; i < n; i++) {
      x = getint(), y = getint();
      fullCnt[x][y]++;
      diaCnt[y]++;
    }
    for (i = 0; i < m; i++) {
      color[i] = getint();
      diameter[i] = getint();
    }
    int r1 = 0, r2 = 0;
    for (i = 0; i < m; i++) {
      if (fullCnt[color[i]][diameter[i]]) {
        fullCnt[color[i]][diameter[i]]--, diaCnt[diameter[i]]--,
            diameter[i] = ~0, r1++, r2++;
      }
    }
    for (i = 0; i < m; i++) {
      if (!~diameter[i]) continue;
      if (diaCnt[diameter[i]]) {
        diaCnt[diameter[i]]--, r1++;
      }
    }
    printf("%d %d\n", r1, r2);
  }
  return 0;
}
