#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5;
const int INF = 1e9 + 1e5 + 2;
const int mod = 1e9 + 7;
int mp[1005][1005];
int cap[1005][1005];
int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    mp[y][x]++;
  }
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    cap[y][x]++;
  }
  int ans = 0, bit = 0;
  for (int i = 1; i <= 1001; ++i) {
    int a = 0, b = 0;
    for (int j = 1; j <= 1001; ++j) {
      int mi = min(mp[i][j], cap[i][j]);
      ans += mi;
      bit += mi;
      mp[i][j] -= mi;
      cap[i][j] -= mi;
      a += mp[i][j];
      b += cap[i][j];
    }
    ans += min(a, b);
  }
  cout << ans << " " << bit;
}
