#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int n, m, a, b;
int f[1010][1010];
int k[1010][1010];
int ans = 0, gans = 0;
int main() {
  cin >> n >> m;
  memset(f, 0, sizeof(f));
  memset(k, 0, sizeof(k));
  for (int i = 0; i < (n); i++) {
    scanf("%d%d", &a, &b);
    f[b][a]++;
    f[b][0]++;
  }
  for (int i = 0; i < (m); i++) {
    scanf("%d%d", &a, &b);
    k[b][a]++;
    k[b][0]++;
  }
  for (int i = 1; i < 1010; i++) {
    ans += min(f[i][0], k[i][0]);
    for (int j = 1; j < 1010; j++) gans += min(f[i][j], k[i][j]);
  }
  cout << ans << " " << gans;
  return 0;
}
