#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, c = 0, b = 0;
  long long p1[1001][1001];
  long long p2[1001];
  long long t[1001];
  memset(p1, 0, sizeof(p1));
  memset(p2, 0, sizeof(p2));
  memset(t, 0, sizeof(t));
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) {
    long long d, c;
    cin >> c >> d;
    p1[d][c]++;
    p2[d]++;
  }
  for (long long i = 0; i < m; ++i) {
    long long d, c;
    cin >> c >> d;
    if (p1[d][c] > 0) {
      p1[d][c]--;
      p2[d]--;
      b++;
    } else {
      t[d]++;
    }
  }
  for (long long i = 0; i < 1001; ++i) {
    c += min(t[i], p2[i]);
  }
  cout << c + b << ' ' << b << endl;
  return 0;
}
