#!/usr/bin/env python3 from sys import argv inp = [({*map(int, y.split())}, {*map(int, z.split())}) for y, z in map(lambda x: x.split(":")[1].split("|"), open(argv[1]).readlines())] m = [sum(z in x for z in y) for x, y in inp] print(sum(1 << (a - 1) if a else 0 for a in m)) n = [1 for x in range(len(inp))] for x in range(len(inp)): for y in range(x + 1, x + m[x] + 1): n[y] += n[x] print(sum(n))