N = int(input()) M = int('1'*12,2)+1 MOD = 998244353 l = [] for _ in range(N): KC = list(map(int,input().split())) c = KC[1:] l.append(c) dp = [[0]*M for _ in range(N+1)] for i in range(1,N+1): C = l[i-1] bit_list = ['0']*12 for c in C: bit_list[c-1] = '1' k = int(''.join(bit_list),2) dp[i][k] = 1 for j in range(M): n = dp[i-1][j] dp[i][j] += n dp[i][j&k] += n dp[i][j&k] %= MOD print(dp[N][0])