#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1010];
int b[1010];
int aa[1010][1010];
int bb[1010][1010];
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x, &y);
    a[y]++;
    aa[y][x]++;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &x, &y);
    b[y]++;
    bb[y][x]++;
  }
  int u = 0;
  for (int i = 1; i <= 1000; ++i) {
    u = u + ((a[i] > b[i]) ? (b[i]) : (a[i]));
  }
  int v = 0;
  for (int i = 1; i <= 1000; ++i) {
    for (int j = 1; j <= 1000; ++j) {
      v = v + ((aa[i][j] > bb[i][j]) ? (bb[i][j]) : (aa[i][j]));
    }
  }
  printf("%d %d\n", u, v);
  return 0;
}
