#include <bits/stdc++.h>
using namespace std;
int a[1001][1001], b[1001][1001];
int main() {
  int i, j;
  int n, m;
  while (cin >> n >> m) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (i = 0; i < n; ++i) {
      int p, q;
      cin >> p >> q;
      ++a[p][q];
    }
    for (i = 0; i < m; ++i) {
      int p, q;
      cin >> p >> q;
      ++b[p][q];
    }
    int s1 = 0, s2 = 0;
    for (i = 1; i <= 1000; ++i) {
      int s3 = 0, s4 = 0;
      for (j = 1; j <= 1000; ++j) {
        int p = min(a[j][i], b[j][i]);
        a[j][i] -= p;
        b[j][i] -= p;
        s1 += p;
        s2 += p;
        s3 += a[j][i];
        s4 += b[j][i];
      }
      s1 += min(s3, s4);
    }
    cout << s1 << ' ' << s2 << endl;
  }
  return 0;
}
