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 def power_list(x, n, mod): res = [1] for _ in range(n): res.append(res[-1] * x % mod) return res ############################################################### N = ip() A = [] for _ in range(N): now = lp() A.append(now[1:]) houjo = [0 for _ in range(2 ** 12)] bit = [0 for _ in range(2 ** 12)] ruijo = power_list(2, N + 10, mod) All = ruijo[N] - 1 for i in range(2 ** 12): g = 0 temp = [] one = 0 for j in range(12): if (i >> j) & 1: one += 1 temp.append(j + 1) bit[i] = one 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] = ruijo[g] - 1 for i in range(1,2 ** 12): one = bit[i] if one & 1: All -= houjo[i] else: All += houjo[i] All %= mod print(All)