## https://yukicoder.me/problems/no/2134 import random MOD = 998244353 def main(): N, M = map(int, input().split()) sets = [] for _ in range(M): values = tuple(map(int, input().split())) sets.append(values[1:]) s_set = set() while len(s_set) < M: a = random.randint(1, 2 ** 63) s_set.add(a) zoblist_hash = list(s_set) elements = [0] * N for i, s in enumerate(sets): for v in s: elements[v - 1] ^= zoblist_hash[i] ans_set = set(elements) l = len(ans_set) print(pow(2, l, MOD)) if __name__ == "__main__": main()