#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  int n, m;
  cin >> n >> m;
  int ms[1002][1002];
  for (int i = 0; i < 1002; i++)
    for (int j = 0; j < 1002; j++) ms[i][j] = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    ms[x][y]++;
    ms[0][y]++;
  }
  int ansIdeal = 0, ansZakr = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (ms[x][y] > 0) {
      ms[x][y]--;
      ms[0][y]--;
      ansIdeal++;
      ansZakr++;
    } else {
      ms[1001][y]++;
    }
  }
  for (int i = 0; i < 1002; i++) ansZakr += min(ms[0][i], ms[1001][i]);
  cout << ansZakr << " " << ansIdeal;
  return 0;
}
