N,M=map(int,input().split())
ks=[[int(a) for a in input().split()] for i in range(M)]
p=[int(a) for a in range(M)]
ans=0

for i in range(2**N):#switch loop
    for j in range(M):#num of light
        sw_see=0
        for k in ks[j][1:]:#switch to see
            sw_see+=2**(k-1)
        if (bin(i&sw_see)).count('1')%2!=p[j]:
            break
    else:
        ans+=1

print(ans)