#include <bits/stdc++.h>
using namespace std;
mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  multiset<pair<int, int>> a;
  map<int, int> ct;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    a.insert({x, y});
    ct[y]++;
  }
  map<int, int> ctb;
  int match = 0, tot = 0;
  for (int i = 0, x, y; i < m; i++) {
    cin >> x >> y;
    if (a.find({x, y}) != a.end()) {
      match++, tot++;
      ct[y]--;
      a.erase(a.find({x, y}));
    } else
      ctb[y]++;
  }
  for (auto &x : ctb) tot += min(x.second, ct[x.first]);
  cout << tot << " " << match << endl;
}
