#include <bits/stdc++.h>
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int main() {
  int n, m, flom_col, flom_sz, colp_col, colp_sz;
  int flom[1005][1005], colp[1005][1005];
  memset(flom, 0, sizeof(flom));
  memset(colp, 0, sizeof(colp));
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &flom_col, &flom_sz);
    flom[flom_sz][flom_col] += 1;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &colp_col, &colp_sz);
    colp[colp_sz][colp_col] += 1;
  }
  int u = 0;
  int v = 0;
  for (int i = 1; i <= 1000; i++)
    for (int j = 1; j <= 1000; j++) {
      if (flom[i][j] > 0 && colp[i][j] > 0) {
        int closed = min(flom[i][j], colp[i][j]);
        flom[i][j] -= closed;
        colp[i][j] -= closed;
        u = u + closed;
      }
    }
  for (int i = 1; i <= 1000; i++) {
    int sum_flom = 0;
    int sum_colp = 0;
    for (int j = 1; j <= 1000; j++) {
      sum_flom += flom[i][j];
      sum_colp += colp[i][j];
    }
    v += min(sum_flom, sum_colp);
  }
  v += u;
  printf("%d %d", v, u);
  return 0;
}
