#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, y, a, b, bu = 0, nonbu = 0;
  vector<vector<long long> > flom(1010);
  vector<long long> col(1010);
  for (int i = 0; i < 1005; i++) flom[i].resize(1010);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    flom[x][y]++;
  }
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (flom[a][b] != 0) {
      flom[a][b]--;
      bu++;
    } else {
      col[b]++;
    }
  }
  for (int i = 0; i < 1004; i++) {
    long long sum = 0;
    for (int j = 0; j < 1004; j++) sum += flom[j][i];
    flom[0][i] = sum;
  }
  nonbu = 0;
  for (int i = 0; i < 1004; i++) {
    if (flom[0][i] < col[i])
      nonbu += flom[0][i];
    else
      nonbu += col[i];
  }
  cout << bu + nonbu << " " << bu << endl;
  return 0;
}
