#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
bool compare(string& a, string& b);
int simple(int);
int nameAdd(string src);
int main() {
  int n = 0, m = 0, buf1, buf2;
  cin >> n >> m;
  int flo[1001][1001], cap[1001][1001];
  for (int i = 0; i < 1001; ++i)
    for (int j = 0; j < 1001; ++j) flo[i][j] = cap[i][j] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> buf1 >> buf2;
    flo[buf2][buf1]++;
    flo[buf2][0]++;
  }
  for (int i = 0; i < m; ++i) {
    cin >> buf1 >> buf2;
    cap[buf2][buf1]++;
    cap[buf2][0]++;
  }
  int close = 0;
  int goodClose = 0;
  for (int i = 1; i < 1001; ++i) {
    if (flo[i][0] >= cap[i][0])
      close += cap[i][0];
    else
      close += flo[i][0];
    for (int j = 1; j < 1001; ++j) {
      if (flo[i][j] >= cap[i][j])
        goodClose += cap[i][j];
      else
        goodClose += flo[i][j];
    }
  }
  cout << close << " " << goodClose << endl;
  return 0;
}
bool compare(string& a, string& b) { return a[0] > b[0]; }
int simple(int src) {
  for (int i = 2; i < (int)sqrt((double)src) + 1; ++i) {
    if (!(src % i)) return 0;
  }
  return 1;
}
