n, m = 10, 10


k = [4, 3, 4, 5, 6, 5, 4, 4, 4, 4]
s = [[6, 3, 7, 5], [1, 10, 5], [8, 7, 1, 2], [5, 10, 2, 7, 8],
     [3, 1, 6, 8, 2, 5], [6, 10, 7, 1, 3], [3, 5, 7, 6],
     [3, 9, 7, 5], [3, 6, 5, 7], [2, 7, 1, 8]]
ans = 0

# for i in range(m):
#     k_temp, *s_temp = list(map(int, input().split()))
#     k.append(k_temp)
#     s.append(s_temp)

p = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1]

for bit in range(1 << n):
    light_on = 0
    for i in range(m):
        switch_on = 0
        for j in range(k[i]):
            if (bit >> s[i][j]) & 1:
                switch_on += 1

        if switch_on % 2 == p[i]:
            light_on += 1

    if light_on == m:
        ans += 1

print(ans)
