#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m, i, j, l, ans;
    scanf("%d %d", &n, &m);
    int sw[n], light[m], p[m], s[m][n], k[m];
    for (i = 0; i < m; i++)
    {
        scanf("%d", &k[i]);
        for (j = 0; j < k[i]; j++)
        {
            scanf("%d", s[i][j]);
        }
    }

    int two = 1;
    for (i = 0; i < n; i++)
    {
        two *= 2;
    }

    string stwo;
    for (i = 0; i < two; i++)
    {
        int i2 = binary(i);
        stwo = to_string(i);
        for (j = 0; j < n; j++)
        {
            sw[j] = stwo[j];
        }

        bool flag = true;
        int a = 0;
        for (j = 0; j < m; j++)
        {
            for (l = 0; l < k[j]; l++)
            {
                if (sw[s[j][l]] == 1)
                    a++;
            }
            flag = flag && a % 2 == p[m];
        }

        if (flag)
            ans++;
    }

    printf("%d", ans);
}

int binary(int bina)
{
    int ans = 0;
    for (int i = 0; bina > 0; i++)
    {
        ans = ans + (bina % 2) * pow(10, i);
        bina = bina / 2;
    }
    return ans;
}