#include <bits/stdc++.h>
using namespace std;
map<int, int> v1;
map<int, int> v2;
struct record {
  int a, b;
  record(int a, int b) {
    this->a = a;
    this->b = b;
  }
};
vector<int> v3[100000 + 1];
vector<int> v4[100000 + 1];
set<int> v5;
int main() {
  int l1, l2, i, x, y, j;
  cin >> l1 >> l2;
  for (i = 1; i <= l1; i++) {
    scanf("%d%d", &x, &y);
    v1[y]++;
    v3[y].push_back(x);
  }
  for (i = 1; i <= l2; i++) {
    scanf("%d%d", &x, &y);
    v2[y]++;
    v4[y].push_back(x);
  }
  long long sum = 0, sum1 = 0;
  for (i = 1; i <= l1 + l2; i++) {
    sum = sum + min(v1[i], v2[i]);
  }
  v1.clear();
  v2.clear();
  sum1 = 0;
  for (i = 1; i <= min(l1 + l2, 100000); i++) {
    if (v3[i].size() == 0 || v4[i].size() == 0) continue;
    for (j = 0; j < v3[i].size(); j++) {
      v1[v3[i][j]]++;
      v5.insert(v3[i][j]);
    }
    for (j = 0; j < v4[i].size(); j++) {
      v2[v4[i][j]]++;
      v5.insert(v4[i][j]);
    }
    set<int>::iterator it;
    for (it = v5.begin(); it != v5.end(); it++) {
      sum1 = sum1 + min(v1[*it], v2[*it]);
    }
    v1.clear();
    v2.clear();
    v5.clear();
  }
  cout << sum << " " << sum1 << "\n";
}
