#include <bits/stdc++.h>
using namespace std;
const int maxs = 1002;
int pens[maxs][maxs];
int caps[maxs][maxs];
int main() {
  memset(pens, 0, sizeof(pens));
  memset(caps, 0, sizeof(caps));
  int n, m;
  int a, b;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    pens[b][a]++;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    caps[b][a]++;
  }
  int res = 0, ans = 0;
  for (int i = 1; i <= 1000; i++) {
    int sum1 = 0, sum2 = 0;
    for (int j = 1; j <= 1000; j++) {
      sum1 += pens[i][j];
      sum2 += caps[i][j];
      ans += std::min(pens[i][j], caps[i][j]);
    }
    res += std::min(sum1, sum2);
  }
  cout << res << " " << ans << endl;
  return 0;
}
