#include <bits/stdc++.h>
using namespace std;
const int sz = 1e3 + 9;
int n, m;
int cnt[sz][sz], cnt2[sz][sz];
int ansb, ansnb;
int a, b;
int main() {
  scanf("%d %d", &n, &m);
  while (n--) {
    scanf("%d %d", &a, &b);
    cnt[b][a]++;
  }
  while (m--) {
    scanf("%d %d", &a, &b);
    cnt2[b][a]++;
  }
  for (int i = 1; i < sz; i++) {
    int reml = 0, remr = 0;
    for (int j = 1; j < sz; j++) {
      int tmp = min(cnt[i][j], cnt2[i][j]);
      ansb += tmp;
      reml += cnt[i][j] - tmp;
      remr += cnt2[i][j] - tmp;
    }
    ansnb += min(reml, remr);
  }
  printf("%d %d", ansnb + ansb, ansb);
  return 0;
}
