#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, ans = 0, c1 = 0, a, b;
  multiset<pair<long long int, long long int> > s, s1;
  pair<long long int, long long int> p;
  long long int h[10003] = {0}, h1[10002] = {0};
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a >> b;
    s.insert({a, b});
    h[b]++;
  }
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    s1.insert({a, b});
    h1[b]++;
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    p = *it;
    if (s1.find(p) != s1.end()) {
      c1++;
      s1.erase(s1.find(p));
    }
  }
  for (i = 1; i <= 1000; i++) {
    if (h1[i] && h[i]) ans += min(h1[i], h[i]);
  }
  cout << ans << " " << c1 << endl;
}
