#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y, b = 0, clos = 0, c[1050];
  int v[1050][1050];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y), v[x][y]++, c[y]++;
  }
  for (int j = 0; j < m; j++) {
    scanf("%d %d", &x, &y);
    if (v[x][y]) b++, v[x][y]--;
    if (c[y]) clos++, c[y]--;
  }
  printf("%d %d", clos, b);
  return 0;
}
