#include <bits/stdc++.h>
using namespace std;
int n, m, ans1, ans2;
vector<int> marker[1010], cap[1010];
int mx = -0x3f3f3f3f, mi = 0x3f3f3f3f;
void read() {
  scanf("%d%d", &n, &m);
  int c, d;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &c, &d);
    marker[d].push_back(c);
    mx = max(mx, d);
    mi = min(mi, d);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &c, &d);
    cap[d].push_back(c);
    mx = max(mx, d);
    mi = min(mi, d);
  }
}
void solve() {
  for (int i = mi; i <= mx; i++) {
    if (marker[i].size()) sort(marker[i].begin(), marker[i].end());
    if (cap[i].size()) sort(cap[i].begin(), cap[i].end());
  }
  int i, j, a, b;
  for (int t = mi; t <= mx; t++) {
    a = marker[t].size();
    b = cap[t].size();
    ans1 += min(b, a);
    i = j = 0;
    while (i < a && j < b) {
      while (cap[t][j] < marker[t][i] && j < b) j++;
      if (j < b && cap[t][j] == marker[t][i]) {
        ans2++;
        j++;
      }
      i++;
    }
  }
  printf("%d %d", ans1, ans2);
}
int main() {
  read();
  solve();
  return 0;
}
