#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T min(T a, T b, T c, T d) {
  return min(a, min(b, min(c, d)));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T max(T a, T b, T c, T d) {
  return max(a, max(b, max(c, d)));
}
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.first > b.first || (a.first == b.first && a.second >= b.second));
}
long long GCD(long long a, long long b) { return (a % b) ? GCD(b, a % b) : b; }
const string namePro = "tmp";
int cnt[1007][1007];
int CNT[1007], tmp[1007];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    ++cnt[x][y];
    ++CNT[y];
  }
  int ans = 0, res = 0;
  for (int j = (1); j <= (m); ++j) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (cnt[u][v]) {
      --cnt[u][v];
      --CNT[v];
      ++ans;
      ++res;
    } else
      ++tmp[v];
  }
  for (int i = (0); i <= (1007); ++i) {
    ans += min(tmp[i], CNT[i]);
  }
  cout << ans << " " << res << endl;
  return 0;
}
