n, m = map(int, input().split()) base = [(1 << n) - 1] for _ in range(m): l, *A = map(int, input().split()) bit = 0 for a in A: bit |= 1 << a - 1 for b in base: if b ^ bit < bit: bit ^= b if bit != 0: base.append(bit) print(pow(2, len(base), 998244353))