#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, gs[1010], ans, ans1;
int vis[1010][1010];
int main() {
  memset(vis, 0, sizeof(vis));
  memset(gs, 0, sizeof(gs));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    vis[x][y]++;
    gs[y]++;
  }
  ans = 0;
  ans1 = 0;
  for (int j = 0; j < m; j++) {
    scanf("%d%d", &x, &y);
    if (gs[y] > 0) {
      ans++;
      gs[y]--;
    }
    if (vis[x][y] > 0) {
      ans1++;
      vis[x][y]--;
    }
  }
  printf("%d %d\n", ans, ans1);
  return 0;
}
