#include <iostream>
#include <vector>
#include <string>
using namespace std ;
using ll = long long ;
int main() {
   int n ;
   cin >> n ;
   vector<ll> v(3*n) ;
   for (int i=0; i<3*n; i++) {
      string s ;
      cin >> s ;
      if (s == "*")
         v[i] = 0xfffffffffffffffLL ;
      else {
         s += "!" ;
         for (int j=0; j<(int)s.size(); j++) {
            int v1 = s[j++]-'0' ;
            if ('0' <= s[j] && s[j] <= '9')
               v1 = 10 * v1 + s[j++]-'0' ;
            if (s[j] != '-') {
               v[i] |= 1LL << v1 ;
            } else {
               j++ ;
               int v2 = s[j++]-'0' ;
               if ('0' <= s[j] && s[j] <= '9')
                  v2 = 10 * v2 + s[j++]-'0' ;
               v[i] |= (2LL<<v2)-(1LL<<v1) ;
            }
         }
      }
   }
   int stot=0, ssec=0 ;
   for (int h=0; h<24; h++)
      for (int m=0; m<60; m++) {
         ll secs = 0 ;
         for (int i=0; i<n; i++)
            if ((v[3*i]>>h)&(v[3*i+1]>>m)&1) {
               secs |= v[3*i+2] ;
               stot += __builtin_popcountll(v[3*i+2]) ;
            }
         ssec += __builtin_popcountll(secs) ;
      }
   cout << ssec << " " << stot << endl ;
}
