#include <bits/stdc++.h>
using namespace std;
const int M = 1e3 + 5;
const int N = 1e5 + 5;
pair<int, int> a[N];
bool ok[N];
int num[M][M];
int b[M];
int32_t main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    num[x][y]++;
  }
  int p = 0, q = 0;
  for (int i = 0; i < n; i++)
    if (num[a[i].first][a[i].second]) {
      p++, q++;
      num[a[i].first][a[i].second]--;
      ok[i] = 1;
    }
  for (int i = 0; i < M; i++)
    for (int j = 0; j < M; j++) b[i] += num[j][i];
  for (int i = 0; i < n; i++)
    if (!ok[i]) {
      if (b[a[i].second]) {
        b[a[i].second]--;
        p++;
      }
    }
  cout << p << ' ' << q << endl;
  return 0;
}
