import sys from operator import itemgetter from collections import defaultdict, deque import heapq import bisect stdin=sys.stdin sys.setrecursionlimit(10 ** 8) ip=lambda: int(sp()) fp=lambda: float(sp()) lp=lambda:list(map(int,stdin.readline().split())) sp=lambda:stdin.readline().rstrip() Yp=lambda:print('Yes') Np=lambda:print('No') inf = 1 << 60 eps = 1e-9 sortkey = itemgetter(0) mod = 998244353 ############################################################### N = ip() A = [] for _ in range(N): now = lp() A.append(now[1:]) houjo = [0 for _ in range(2 ** 12)] All = pow(2, N, mod) - 1 for i in range(2 ** 12): g = 0 temp = [] for j in range(12): if (i >> j) & 1: temp.append(j + 1) for j in range(N): flag = True for get in temp: if not get in A[j]: flag = False if flag: g += 1 houjo[i] = pow(2, g, mod) - 1 for i in range(1,2 ** 12): one = 0 for j in range(12): if (i >> j) & 1: one += 1 if one & 1: All -= houjo[i] else: All += houjo[i] All %= mod print(All)