N = int(input()) MOD = 998244353 B = [] for _ in range(N): L = list(map(int,input().split())) C = L[1:] b = 0 for c in C: b += 1<<(c-1) B.append(b) ans = 0 for bit in range(1<<12): cnt = 0 sgn = (-1)**bin(bit).count("1") for b in B: if bit&b == bit: cnt += 1 ans += (pow(2,cnt,MOD)-1)*sgn ans %= MOD print(ans)