n, m = map(int, input().split()) A = [0]*m contain = [0]*n for i in range(m): l, *a = map(int, input().split()) for aj in a: A[i] |= (1 << (aj-1)) for i in range(0,n): for j in range(0,m): if A[j] & (1 << i) != 0: contain[i] |= (1 << j) sets = set() for i in range(0,n): sets.add(contain[i]) size = len(sets) print(pow(2,size,998244353))