#include <bits/stdc++.h>
using namespace std;
int a[1005][1005], b[1005][1005], a_cnt[1005], b_cnt[1005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a[x][y]++;
    a_cnt[y]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    b[x][y]++;
    b_cnt[y]++;
  }
  int closed = 0, beau = 0;
  for (int i = 0; i <= 1000; i++) closed += min(a_cnt[i], b_cnt[i]);
  for (int i = 0; i <= 1000; i++)
    for (int j = 0; j <= 1000; j++) beau += min(a[i][j], b[i][j]);
  cout << closed << " " << beau << '\n';
  return 0;
}
