#include <bits/stdc++.h>
using namespace std;
int N, M, x, y;
int Cnt[1005];
multiset<pair<int, int> > A, B;
int main() {
  scanf("%d%d", &N, &M);
  A.clear();
  B.clear();
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    A.insert(make_pair(a, b));
    Cnt[b]++;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    B.insert(make_pair(a, b));
    if (Cnt[b]) {
      x++;
      Cnt[b]--;
    }
  }
  for (multiset<pair<int, int> >::iterator it = A.begin(); it != A.end(); it++)
    if (B.find(*it) != B.end()) {
      B.erase(B.find(*it));
      y++;
    }
  printf("%d %d\n", x, y);
  return 0;
}
