#include <bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
int main() {
  int n, m;
  int a, b;
  int sol1 = 0, sol2 = 0;
  map<pair<int, int>, int> mp1, mp2;
  map<pair<int, int>, int>::iterator it1, it2;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a, &b);
    mp1[make_pair(b, a)]++;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a, &b);
    mp2[make_pair(b, a)]++;
  }
  for (it1 = mp2.begin(); it1 != mp2.end(); it1++) {
    int add = min(mp1[it1->first], mp2[it1->first]);
    it1->second -= add;
    mp1[it1->first] -= add;
    sol2 += add;
    sol1 += add;
  }
  it1 = mp1.begin();
  it2 = mp2.begin();
  while (it1 != mp1.end() && it2 != mp2.end()) {
    int p = 0;
    if (it1->second == 0) {
      it1++;
      p = 1;
    }
    if (it2->second == 0) {
      it2++;
      p = 1;
    }
    if (p) continue;
    if ((*it1).first.first == (*it2).first.first) {
      if (it1->second == 0)
        it1++;
      else
        it1->second--;
      if (it2->second == 0)
        it2++;
      else
        it2->second--;
      sol1++;
    } else {
      if ((*it1).first.first > (*it2).first.first) {
        it2++;
      } else {
        it1++;
      }
    }
  }
  printf("%d %d\n", sol1, sol2);
  return 0;
}
