#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  int n, m, x, y, v = 0, w = 0;
  cin >> n >> m;
  vector<vector<int> > a(1001), b(1001);
  for (int i = 0; i < (1001); ++i) {
    a[i].resize(1001);
    b[i].resize(1001);
  }
  vector<int> aa(1001), bb(1001);
  for (int i = 0; i < (n); ++i) {
    cin >> y >> x;
    ++a[x][y];
    ++aa[x];
  }
  for (int i = 0; i < (m); ++i) {
    cin >> y >> x;
    ++b[x][y];
    ++bb[x];
  }
  for (int i = 0; i < int((aa).size()); ++i) w += min(aa[i], bb[i]);
  for (int i = 0; i < int((a).size()); ++i)
    for (int j = 0; j < int(((a)[i]).size()); ++j) v += min(a[i][j], b[i][j]);
  cout << w << ' ' << v << endl;
  return 0;
}
