#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N, M;
int K[11];
int S[11][11];
int P[11];
int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> K[i];
        rep(k, K[i]) {
            int nu;
            cin >> nu;
            S[i][k] = nu -1;
        }
    }
    int ans = 0;
    rep(i, M) {
        cin >> P[i];
    }
    for(int bit = 0; bit < (1<<N); bit++) {
        int mana[11];
        memset(mana, 0, sizeof(mana));
        sort(S[m], S[m]+K[m]);

        for(int i = 0; i < N; i++) {
            if(bit & (1<<i)) {
                rep(m, M) {
                    if(binary_search(S[m], S[m] + K[m], i)) {
                        mana[m] += 1;
                    }
                }
            }

        }
        bool flag = true;
        rep(i, M) {
            if(mana[i] % 2 != P[i]) flag = false;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}
