#include <bits/stdc++.h>
using namespace std;
int capsDC[1010][1010];
int capsD[1010];
int remainingMarkers[1010];
int main() {
  memset(capsDC, 0, sizeof capsDC);
  memset(capsD, 0, sizeof capsD);
  memset(remainingMarkers, 0, sizeof remainingMarkers);
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    capsDC[a][b]++;
    capsD[b]++;
  }
  int beau = 0, non = 0;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    if (capsDC[a][b] != 0) {
      capsDC[a][b]--;
      capsD[b]--;
      beau++;
    } else {
      remainingMarkers[b]++;
    }
  }
  for (int i = 0; i < 1010; ++i) {
    non += min(remainingMarkers[i], capsD[i]);
  }
  cout << non + beau << ' ' << beau << endl;
}
