#include <bits/stdc++.h>
int tab[1000][1000];
int count[1000];
int main() {
  for (int i = 0; i < 1000; i++) {
    count[i] = 0;
    for (int j = 0; j < 1000; j++) tab[i][j] = 0;
  }
  int N, M;
  std::cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int x, y;
    std::cin >> x >> y;
    x--;
    y--;
    tab[x][y]++;
    count[y]++;
  }
  int res1 = 0, res2 = 0;
  for (int i = 0; i < M; i++) {
    int x, y;
    std::cin >> x >> y;
    x--, y--;
    if (count[y]) {
      res1++;
      count[y]--;
    }
    if (tab[x][y]) {
      res2++;
      tab[x][y]--;
    }
  }
  std::cout << res1 << ' ' << res2 << '\n';
  return 0;
}
