#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, ans;
map<pair<int, int>, int> mp2, mp3;
map<int, int> mp, mp1;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  ans = 0;
  while (n--) {
    cin >> x >> y;
    mp[y]++;
    mp2[{x, y}]++;
  }
  while (m--) {
    cin >> x >> y;
    mp1[y]++;
    mp3[{x, y}]++;
  }
  for (auto i : mp)
    if (mp1[i.first]) ans += min(i.second, mp1[i.first]);
  cout << ans << " ";
  ans = 0;
  for (auto i : mp2)
    if (mp3[i.first]) ans += min(i.second, mp3[i.first]);
  cout << ans << endl;
}
