#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int N, M;
map<int, int> mp[MAXN];
int cnt[MAXN], cnt2[MAXN];
int main() {
  cin >> N >> M;
  int beau = 0;
  while (N--) {
    int a, b;
    scanf("%d %d", &a, &b);
    ++mp[b][a];
    ++cnt[b];
  }
  while (M--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (mp[b][a]) {
      --cnt[b];
      ++beau;
      --mp[b][a];
    } else {
      ++cnt2[b];
    }
  }
  int ans = beau;
  for (int i = 0; i < MAXN; ++i) {
    ans += min(cnt[i], cnt2[i]);
  }
  cout << ans << " " << beau << endl;
  return 0;
}
