import sys input = sys.stdin.readline from collections import * N = int(input()) S = [] for _ in range(N): kC = list(map(int, input().split())) Si = 0 for Ci in kC[1:]: Si += 1<<(Ci-1) S.append(Si) ans = 0 MOD = 998244353 for M in range(1<<12): c = 0 for Si in S: if Si&M==M: c += 1 bit_c = 0 for i in range(12): if (M>>i)&1: bit_c += 1 if bit_c%2==0: ans += pow(2, c, MOD)-1 else: ans -= pow(2, c, MOD)-1 ans %= MOD print(ans)