import collections N = int(input()) # bitDP mod = 998244353 ll = 12 dp = [0]*(2**ll) dp[-1] = 1 for i in range(N): ls = list(map(int,input().split())) dp2 = [0]*(2**ll) k = ls.pop(0) a = 0 for j in ls: a += 2**(j-1) for j in range(2**ll-1,-1,-1): dp2[j&a] += dp[j] dp2[j] += dp[j] dp2[j&a] %= mod dp2[j] %= mod dp = dp2 print(dp[0]%mod)