#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 10;
inline long long add(long long x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline long long mul(long long x, long long y) {
  x = (1LL * x * y) % mod;
  return x;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  int freq1[1001] = {0};
  int freq2[1001][1001] = {{0}};
  int c[n + 1];
  int d[n + 1];
  for (long long i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    c[i] = x;
    d[i] = y;
  }
  for (long long i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    freq2[x][y]++;
    freq1[y]++;
  }
  int ans1 = 0;
  int ans2 = 0;
  for (long long i = 1; i <= n; ++i) {
    if (freq2[c[i]][d[i]] > 0)
      ans1++, ans2++, freq2[c[i]][d[i]]--, freq1[d[i]]--, c[i] = 0;
  }
  for (long long i = 1; i <= n; ++i) {
    if (c[i] != 0) {
      if (freq1[d[i]] > 0) ans2++, freq1[d[i]]--;
    }
  }
  cout << ans2 << " " << ans1 << "\n";
  return 0;
}
