#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const double EPS = 1e-9;
int b[1009][1009];
int r[1009];
vector<pair<int, int>> a;
void solve(int test) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    b[x][y]++;
    r[y]++;
  }
  int u = 0, v = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (b[x][y] > 0)
      u++, v++, b[x][y]--, r[y]--;
    else
      a.push_back(make_pair(x, y));
  }
  for (int i = 0; i < int(a.size()); i++) {
    if (r[a[i].second] > 0) u++, r[a[i].second]--;
  }
  cout << u << ' ' << v << endl;
}
int main() {
  solve(0);
  return 0;
}
