def encode(S): X=0 for s in S: X+=1<<(s-1) return X N=int(input()) Mod=998244353 DP=[0]*(1<<12); DP[-1]=1 for _ in range(N): k,*C=map(int,input().split()) y=encode(C) for x in range(1<<12): DP[x&y]+=DP[x] for x in range(1<<12): DP[x]%=Mod print(DP[0])