#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  while (scanf("%d%d", &N, &M) != EOF) {
    map<int, int> c1, c2;
    map<pair<int, int>, int> b1, b2;
    for (int i = 0; i < (int)(N); ++i) {
      int a, b;
      scanf("%d%d", &a, &b);
      c1[b]++;
      b1[make_pair(a, b)]++;
    }
    for (int i = 0; i < (int)(M); ++i) {
      int a, b;
      scanf("%d%d", &a, &b);
      c2[b]++;
      b2[make_pair(a, b)]++;
    }
    int cres = 0, bres = 0;
    for (__typeof((c1).begin()) ct = (c1).begin(); ct != (c1).end(); ++ct)
      cres += min(ct->second, c2[ct->first]);
    for (__typeof((b1).begin()) bt = (b1).begin(); bt != (b1).end(); ++bt)
      bres += min(bt->second, b2[bt->first]);
    printf("%d %d\n", cres, bres);
  }
}
