#include <bits/stdc++.h>
int main(void) {
  int n, t, i, blow[50] = {0}, hit[50] = {0};
  scanf("%d", &n);
  t = n;
  while (n) {
    int a1, a2, a3, a4, b1, b2, b3, b4;
    scanf("%d %d %d %d", &a1, &a2, &a3, &a4);
    scanf("%d %d %d %d", &b1, &b2, &b3, &b4);
    int j, a[] = {a1, a2, a3, a4}, b[] = {b1, b2, b3, b4};
    for (i = 0; i < 4; i++)
      for (j = 0; j < 4; j++) {
        if (a[i] == b[i]) {
          hit[t - n]++;
          break;
        }
        if (a[i] == b[j]) blow[t - n]++;
      }
    n--;
  }
  for (i = 0; i < t; i++) {
    printf("%d %d\n", hit[i], blow[i]);
  }
  return 0;
}
