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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<pair<int, vector<int>>> ks(m);
    int s;
    vector<int> p(m);

    for (int i = 0; i < m; i++)
    {
        cin >> ks[i].first;
        for (int j = 0; j < ks[i].first; j++)
        {
            cin >> s;
            ks[i].second.push_back(s);
        }
    }
    
    for (int i = 0; i < m; i++)
        cin >> p[i];

    int sw_iter = 0x000;
    int count = 0;
    vector<int> swval(n);
    bool match;
    int num_sw_on; =0;
    for (int i = 0; i < (0x1<<n), i++)
    {
        match = true;

        for (int j = 0; j < n; j++)
        {
            swval[j] = i & (0x1 << j);
        }

        for (int k = 0; k < m; k++)
        {
            num_sw_on = 0;
            for (int l = 0; l < ks[i].first; l++)
                if (swval[(ks[i].second[l]-1)] == true) num_sw_on++;

            if (num_sw_on % 2 != p[k]) match = false;
        }

        if (match) count++;

    }
        
    cout << count << endl;
}
