#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1002;
int cy[MAXN], my[MAXN], cyx[MAXN][MAXN], myx[MAXN][MAXN];
int main() {
  int N, M, x, y;
  long long retc = 0, retb = 0;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    my[y]++;
    myx[y][x]++;
  }
  for (int j = 0; j < M; j++) {
    cin >> x >> y;
    cy[y]++;
    cyx[y][x]++;
  }
  for (int i = 1; i <= 1000; i++) {
    retc += min(my[i], cy[i]);
    for (int j = 1; j <= 1000; j++) {
      retb += min(myx[i][j], cyx[i][j]);
    }
  }
  cout << retc << ' ' << retb << endl;
}
