n=int(input()) p=[0]*n for i in range(n): k,*c,=list(map(int,input().split())) for j in range(k): p[i]|=1<<(c[j]-1) M=998244353 l=12 a=0 for i in range(1<