#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::map<int, int>> A(1001), B(1001);
  std::vector<int> AN(1001), BN(1001);
  for (int i = 0; i < n; ++i) {
    int x, y;
    std::cin >> x >> y;
    ++AN[y];
    ++A[y][x];
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    std::cin >> x >> y;
    ++BN[y];
    ++B[y][x];
  }
  int covered = 0;
  int match = 0;
  for (int i = 1; i <= 1000; ++i) {
    covered += std::min(AN[i], BN[i]);
    for (auto p : A[i]) {
      match += std::min(p.second, B[i][p.first]);
    }
  }
  std::cout << covered << ' ' << match << '\n';
}
