import sys input = sys.stdin.readline N=int(input()) mod=998244353 S=[list(map(int,input().split()))[1:] for i in range(N)] DP=[0]*(1<