#include <bits/stdc++.h>
using namespace std;
int M[1010][1010] = {}, C[1010][1010] = {};
int main() {
  int n, m;
  cin >> n >> m;
  memset(M, 0, sizeof(M));
  memset(C, 0, sizeof(C));
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    M[y][x]++;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    C[y][x]++;
  }
  int x = 0, y = 0;
  for (int i = 0; i < 1010; i++) {
    int sa = 0, sb = 0;
    for (int j = 0; j < 1010; j++) {
      sa += M[i][j];
      sb += C[i][j];
      y += min(M[i][j], C[i][j]);
    }
    x += min(sa, sb);
  }
  cout << x << " " << y << endl;
}
