#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,M;
map<int,int> m[20];
int P[20];

int main(void) {
    cin>>N>>M;

    for(int i = 1;i <= M;i++) {
        int k;
        cin>>k;
        for(int j = 0;j < k;j++) {
            int s;
            cin>>s;
            m[i][s] = 1;
        }
    }

    for(int i = 1;i <= M;i++) {
        int p;
        cin>>p;
        P[i] = p;
    }

    int d;
    int ans = 0;
    d = (1<<N);
    for(int bit = 1;bit < d;bit++) {
        int num = bit;
        int score[N+1] = {0};
        for(int i = 0;i < N;i++) {
            if((num>>i) & 1) {
                int swit = i+1;
                for(int j = 1;j <= M;j++) {
                    if(m[j].count(swit) != 0)
                        score[j]++;
                }
            }
        }

        bool flag = true;
        for(int i = 1;i<= M;i++) {
            if(score[i] % 2 != P[i])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}
