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

int main(void)
{
    int N, M, k;
    cin >> N >> M;
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> s[i][j];
            --s[i][j]
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];

    int ans = 0
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int counter = 0;
            for (int j = 0; j < s[i].size(); ++j) {
                if (bit & (1<<s[i][j])) counter++;
            }
            if (counter % 2 != p[i]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}
