#!/usr/bin/env python3

import itertools

def parse(spec: str, max_val: int):
    if spec == "*":
        return set(range(max_val))
    elif "," in spec:
        subspecs = spec.split(",")
        return set.union(*[parse(sub, max_val) for sub in subspecs])
    elif "-" in spec:
        a, b = map(int, spec.split("-"))
        return set(range(a, b + 1))
    else:
        return {int(spec)}

def main():
    n = int(input())
    ans = set()
    total = 0
    for _ in range(n):
        specs = input().split()
        valid = [parse(spec, max_val) for spec, max_val in zip(specs, [24, 60, 60])]
        ans |= set(itertools.product(*valid))
        total += len(valid[0]) * len(valid[1]) * len(valid[2])
		
    print(len(ans),total)

if __name__ == "__main__":
    main()
