#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e+3 + 10;
int a[LIM][2][LIM];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int color, d;
    cin >> color >> d;
    a[d][0][color]++;
  }
  for (int i = 0; i < m; i++) {
    int color, d;
    cin >> color >> d;
    a[d][1][color]++;
  }
  int ans = 0;
  int nice = 0;
  for (int i = 0; i < LIM; i++) {
    int f = 0;
    int k = 0;
    for (int j = 0; j < LIM; j++) {
      f += a[i][0][j];
      k += a[i][1][j];
      nice += min(a[i][0][j], a[i][1][j]);
    }
    ans += min(f, k);
  }
  cout << ans << ' ' << nice;
  return 0;
}
