import sys input = sys.stdin.readline N = int(input()) mod = 998244353 m = 12 dp = [0] * (1 << m) for _ in range(N): c = list(map(int, input().split())) t = 0 if c[0]: for x in c[1: ]: t |= 1 << (x - 1) for i in range(1 << m): dp[i & t] += dp[i] dp[i & t] %= mod dp[t] += 1 dp[t] %= mod print(dp[0])