#include <bits/stdc++.h>
using namespace std;
int Beauty[1001][1001];
int cap[1001][1001];
int input[1001][1001];
int total;
int perfect;
int main() {
  int n, m;
  int colsumcap[1001] = {0};
  int colsumpen[1001] = {0};
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    input[x][y]++;
    colsumpen[y]++;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    cap[x][y]++;
    colsumcap[y]++;
  }
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (cap[i][j] > 0 && input[i][j] > 0) {
        int a = cap[i][j] < input[i][j] ? cap[i][j] : input[i][j];
        perfect += a;
        total += a;
        cap[i][j] -= a;
        input[i][j] -= a;
        colsumpen[j] -= a;
        colsumcap[j] -= a;
      }
    }
  }
  for (int i = 1; i <= 1001; i++) {
    if (colsumpen[i] > 0 && colsumcap[i] > 0) {
      int a = colsumpen[i] < colsumcap[i] ? colsumpen[i] : colsumcap[i];
      total += a;
    }
  }
  cout << total << " " << perfect << endl;
  return 0;
}
