N, M = map(int, input().split())
s = [0] * N
for i in range(M):
    k = list(map(int, input().split()))
    for a in k[1:]:
        s[a-1] = s[a-1] + 1
ans = 0
for i in s:
    if i <= 1:
        if ans == 0: ans = 1
        else: ans = ans * 2
print(ans)