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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
using INT64 = long long;

int main(void)
{
    IOS
    int n,m;
    cin >> n>>m;
    vector<int> p(m);
    vector<bitset<11>> d;
    for(int i = 0; i < m; i++){
        bitset<11> bs(0);
        int k;
        cin >> k;
        for (int j = 0; j < k;j++) {
            int s;
            cin >> s;
            bs.set(s-1);
        }
        //cerr << bs << endl;
        d.push_back(bs);
    }
    for(int i = 0; i < m;i++) cin >> p[i];

    unsigned int sw = 1 << (n);

    int ans=0;
    for(unsigned int i = 1; i < sw;i++){
        bitset<11> ssw(i);
        cerr << ssw << endl;
        bool flag = true;
        for (int j = 0; j < m; j++) {
            bitset<10> sk = d[j];
            //cerr << sk << endl;
            sk &= ssw;
            int count = sk.count();
            //cerr << count << endl;
            if (count % 2 != p[j]) {
                flag = false;
                break;
            }
            if (!flag) break;
        }
        if (flag) ans++;
    }

    cout << ans << endl; 
    return 0;
}