#include <cassert>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

void read(vector<int>& v) {
  string s;
  cin >> s;
  if (s == "*") { v = vector<int>(v.size(), 1); return; }
  istringstream sin(s);
  int last = -1;
  for (;;) {
    int x, y;
    char ch = 0;
    if (!(sin >> x)) break;
    assert(x > last && x < v.size());
    last = x;
    if (!(sin >> ch) || ch == ',') {
      assert(!v[x]);
      v[x] = 1;
    } else {
      assert(ch == '-');
      sin >> y >> ch;
      assert(y > last && y < v.size());
      last = y;
      for (int i = x; i <= y; i++) {
        assert(!v[i]);
        v[i] = 1;
      }
    }
  }
}

int main() {
  int N;
  while (cin >> N) {
    vector<vector<int>> H(N, vector<int>(24));
    vector<vector<int>> M(N, vector<int>(60));
    vector<vector<int>> S(N, vector<int>(60));
    for (int i = 0; i < N; i++) {
      read(H[i]);
      read(M[i]);
      read(S[i]);
    }

    int ret1 = 0, ret2 = 0;
    for (int h = 0; h < 24; h++)
    for (int m = 0; m < 60; m++)
    for (int s = 0; s < 60; s++) {
      int seen = 0;
      for (int i = 0; i < N; i++) {
        if (!H[i][h] || !M[i][m] || !S[i][s]) continue;
        seen = 1;
        ret2++;
      }
      ret1 += seen;
    }
    cout << ret1 << ' ' << ret2 << endl;
  }
}
