#include <bits/stdc++.h>
using namespace std;
struct attr {
  int col;
  int dia;
};
bool sorting(attr a, attr b) {
  if (a.dia == b.dia) return a.col < b.col;
  return a.dia < b.dia;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, i, j, count = 0, scount = 0;
  cin >> n >> m;
  attr mark[n], cap[m];
  for (i = 0; i < n; i++) {
    cin >> mark[i].col >> mark[i].dia;
  }
  for (i = 0; i < m; i++) {
    cin >> cap[i].col >> cap[i].dia;
  }
  sort(mark, mark + n, sorting);
  sort(cap, cap + m, sorting);
  for (i = 0, j = 0; i < n && j < m;) {
    if (mark[i].dia > cap[j].dia)
      j++;
    else if (mark[i].dia < cap[j].dia)
      i++;
    else {
      i++;
      j++;
      count++;
    }
  }
  for (i = 0, j = 0; i < n && j < m;) {
    if (mark[i].dia > cap[j].dia)
      j++;
    else if (mark[i].dia < cap[j].dia)
      i++;
    else {
      if (mark[i].col > cap[j].col)
        j++;
      else if (mark[i].col < cap[j].col)
        i++;
      else {
        i++;
        j++;
        scount++;
      }
    }
  }
  cout << count << " " << scount;
  return 0;
}
