#include <bits/stdc++.h>
using namespace std;
int a[1002][1002], b[1002][1002];
int main() {
  int i, k, n, m, x, y, mx = 0, mn = 0, c[1002] = {0};
  map<int, int> mp;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    a[x][y] = a[x][y] + 1;
    c[y]++;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    b[x][y] = b[x][y] + 1;
    mp[y] = mp[y] + 1;
  }
  for (i = 0; i <= 1000; i++)
    for (k = 0; k <= 1000; k++) {
      if (a[i][k] <= b[i][k]) {
        mx = mx + a[i][k];
      } else
        mx = mx + b[i][k];
    }
  for (i = 0; i <= 1000; i++) {
    if (c[i] > 0) {
      x = c[i];
      y = mp[i];
      if (y >= x)
        mn = mn + x;
      else
        mn = mn + y;
    }
  }
  printf("%d %d\n", mn, mx);
  return 0;
}
