#include <bits/stdc++.h>
using namespace std;
struct cd {
  int col, dim;
  bool operator<(const cd &b) const {
    return dim < b.dim || dim == b.dim && col < b.col;
  }
};
cd marker[100005], cap[100005];
int n, m, h1[1005], h2[1005], hh1[100005], hh2[100005], s1, s2;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(h1, 0, sizeof(h1));
    memset(h2, 0, sizeof(h2));
    s1 = 0;
    s2 = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &marker[i].col, &marker[i].dim);
      h1[marker[i].dim]++;
      hh1[i] = marker[i].col * 1000 + marker[i].dim;
    }
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &cap[i].col, &cap[i].dim);
      h2[cap[i].dim]++;
      hh2[i] = cap[i].col * 1000 + cap[i].dim;
    }
    for (int i = 0; i < 1005; i++) {
      s1 += min(h1[i], h2[i]);
    }
    sort(hh1, hh1 + n);
    sort(hh2, hh2 + m);
    int i = 0, j = 0;
    while (i < n && j < m) {
      if (hh1[i] == hh2[j]) {
        i++;
        j++;
        s2++;
      } else if (hh1[i] < hh2[j])
        i++;
      else
        j++;
    }
    printf("%d %d\n", s1, s2);
  }
  return 0;
}
