#include <bits/stdc++.h>
using namespace std;
int app[1020][1020], cnt[200000];
pair<int, int> UnS[200000];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  memset(app, 0, sizeof(app));
  int x, y;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    ++app[y][x];
  }
  int rem = 0, ans = 0, tans = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if (app[y][x]) {
      ++ans;
      --app[y][x];
      continue;
    }
    UnS[++rem] = make_pair(y, x);
  }
  for (int i = 1; i <= 1020; ++i)
    for (int j = 1; j <= 1020; ++j) cnt[i] += app[i][j];
  for (int i = 1; i <= rem; ++i)
    if (cnt[UnS[i].first]) {
      ++tans;
      --cnt[UnS[i].first];
    }
  printf("%d %d\n", ans + tans, ans);
  return 0;
}
