import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline import pypyjit pypyjit.set_param('max_unroll_recursion=-1') from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd mod = 998244353 n,m = map(int,input().split()) A = [0]*m Ac = [0]*m B = [(2**n - 1)]*n for i in range(m): l, *a = map(int,input().split()) for j in range(l): A[i] |= 1 << (a[j] - 1) Ac[i] = ~A[i] for j in range(n): if (A[i] >> j) & 1: B[j] &= A[i] else: B[j] &= Ac[i] s = set() for i in range(n): s.add(B[i]) print(pow(2, len(s), mod))