#include <bits/stdc++.h>
using namespace std;
int n, m;
unsigned int i, j, k;
int ca[1001][1001];
int ma[1001][1001];
int tm[1001];
int cm[1001];
int b, s;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  while (n-- > 0) {
    cin >> j >> k;
    ++ma[j][k];
    ++tm[k];
  }
  while (m-- > 0) {
    cin >> j >> k;
    ++ca[j][k];
    ++cm[k];
  }
  for (j = 1; j <= 1000; ++j) {
    if (cm[j] == 0 || tm[j] == 0) continue;
    for (i = 1; i <= 1000; ++i) {
      m = ((ca[i][j]) < (ma[i][j])) ? (ca[i][j]) : (ma[i][j]);
      b += m;
      s += m;
      tm[j] -= m;
      cm[j] -= m;
    }
    s += ((tm[j]) < (cm[j])) ? (tm[j]) : (cm[j]);
  }
  cout << s << " " << b << "\n";
  return 0;
}
