#include <bits/stdc++.h>
using namespace std;
const int Max = 1e5 + 5;
struct node {
  int x, y;
} Node1[Max], Node2[Max];
int hash1[Max], hash2[Max];
bool cmp(const node a, const node b) {
  if (a.y == b.y) return a.x < b.x;
  return a.y < b.y;
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(hash1, 0, sizeof(hash1));
    memset(hash2, 0, sizeof(hash2));
    for (int i = 0; i < n; ++i) {
      scanf("%d%d", &Node1[i].x, &Node1[i].y);
      hash1[Node1[i].y]++;
    }
    for (int i = 0; i < m; ++i) {
      scanf("%d%d", &Node2[i].x, &Node2[i].y);
      hash2[Node2[i].y]++;
    }
    int coun = 0;
    for (int i = 0; i <= 1000; ++i) {
      if (hash1[i] > 0 && hash2[i] > 0)
        coun += (max(hash1[i], hash2[i]) - abs(hash1[i] - hash2[i]));
    }
    sort(Node1, Node1 + n, cmp);
    sort(Node2, Node2 + m, cmp);
    int i = 0, j = 0, cou = 0;
    while (i < n && j < m) {
      if (Node1[i].y == Node2[j].y) {
        if (Node1[i].x == Node2[j].x) {
          cou++;
          i++;
          j++;
        } else if (Node1[i].x < Node2[j].x)
          i++;
        else
          j++;
      } else if (Node1[i].y < Node2[j].y)
        i++;
      else
        j++;
    }
    printf("%d %d\n", coun, cou);
  }
  return 0;
}
