#include <bits/stdc++.h>
using namespace std;
int p[1001][1001];
int r[1001][1001];
int main() {
  int n, m, i, j, k, l, t, x, y;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(p, 0, sizeof(p));
    memset(r, 0, sizeof(r));
    for (i = 0; i < n; i++) {
      scanf("%d%d", &x, &y);
      p[x][y]++;
    }
    for (i = 0; i < m; i++) {
      scanf("%d%d", &x, &y);
      r[x][y]++;
    }
    int sum = 0, num = 0;
    for (i = 1; i <= 1000; i++)
      for (j = 1; j <= 1000; j++) {
        int R = p[i][j] > r[i][j] ? r[i][j] : p[i][j];
        num += R;
        p[i][j] -= R;
        r[i][j] -= R;
      }
    for (i = 1; i <= 1000; i++) {
      p[0][i] = 0;
      r[0][i] = 0;
      for (j = 1; j <= 1000; j++) {
        p[0][i] += p[j][i];
        r[0][i] += r[j][i];
      }
      int R = p[0][i] > r[0][i] ? r[0][i] : p[0][i];
      sum += R;
    }
    printf("%d %d\n", sum + num, num);
  }
  return 0;
}
