#include <bits/stdc++.h>
using namespace std;
int n, m, s[210000][3];
int cmp(const void *a, const void *b) {
  int *c = (int *)a, *d = (int *)b;
  if (c[1] != d[1]) return c[1] - d[1];
  return c[0] - d[0];
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    s[i][2] = 0;
    scanf("%d %d", &s[i][0], &s[i][1]);
  }
  for (int i = 1; i <= m; ++i) {
    s[i + n][2] = 1;
    scanf("%d %d", &s[i + n][0], &s[i + n][1]);
  }
  qsort(&s[1], n + m, sizeof(s[0]), cmp);
  s[0][0] = s[0][1] = s[0][2] = 0;
  int prex = 0, prey = 0;
  int cnty1 = 0, cnty2 = 0, cntxy1 = 0, cntxy2 = 0, ansy = 0, ansxy = 0;
  for (int i = 1; i <= n + m; ++i) {
    if (s[i][0] == prex && s[i][1] == prey) {
      if (!s[i][2])
        cnty1++, cntxy1++;
      else
        cnty2++, cntxy2++;
    } else if (s[i][1] == prey) {
      prex = s[i][0];
      ansxy += min(cntxy1, cntxy2);
      cntxy1 = cntxy2 = 0;
      if (!s[i][2])
        cnty1++, cntxy1++;
      else
        cnty2++, cntxy2++;
    } else {
      prex = s[i][0];
      prey = s[i][1];
      ansxy += min(cntxy1, cntxy2);
      ansy += min(cnty1, cnty2);
      cntxy1 = cntxy2 = 0;
      cnty1 = cnty2 = 0;
      if (!s[i][2])
        cnty1++, cntxy1++;
      else
        cnty2++, cntxy2++;
    }
  }
  ansxy += min(cntxy1, cntxy2);
  ansy += min(cnty1, cnty2);
  printf("%d %d\n", ansy, ansxy);
  return 0;
}
