#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int b[1001][1001];
int main() {
  int n, m, c, d, u = 0, v = 0;
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c >> d;
    a[d][c]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> c >> d;
    b[d][c]++;
  }
  for (d = 0; d < 1001; d++) {
    int sumA = 0;
    int sumB = 0;
    int equals = 0;
    for (c = 0; c < 1001; c++) {
      sumA += a[d][c];
      sumB += b[d][c];
      equals += min(a[d][c], b[d][c]);
    }
    u += min(sumA, sumB);
    v += equals;
  }
  cout << u << " " << v;
}
