#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < (int)(n); i++)
using ull = unsigned long long;
using ll = long long;

int D1[10] = {};
int D2[100] = {};
int D3[1000] = {};

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

    bool Sk[M][N] = {};
    int k, sj;
    rep(i, M) {
        cin >> k;
        rep(j, k) {
            cin >> sj;
            Sk[i][sj] = true;
        }
    }

    bool P[15];
    rep(i, M) cin >> P[i];

    int ans = 0;
    for (int bit=0; bit<(1<<N); bit++) {
        bool all_light = true;
        rep(m, M) {
            int cnt_on = 0;
            rep(n, N) {
                if ((Sk[m][n]) && (bit & 1<<n)) cnt_on++;
            }
            if (cnt_on%2 != P[m]) all_light = false;
        }
        if (all_light) ans++;
    }

    cout << ans << endl;

    return 0;
}

