MOD = 998244353 n = int(input()) m = 12 d = [0] * (1 << m) for _ in range(n): _, *c = map(int, input().split()) s = sum(1 << x - 1 for x in c) d[s] += 1 for k in range(m): for s in range(1 << m): if s >> k & 1: d[s ^ 1 << k] += d[s] for s in range(1 << m): d[s] = pow(2, d[s], MOD) for k in range(m): for s in range(1 << m): if s >> k & 1: d[s ^ 1 << k] -= d[s] d[s ^ 1 << k] %= MOD print(d[0])