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

int main() {
    int n, m;
    cin >> n >> m; 
    vector<int> a(n);
    rep(i,m) {
        int k;
        cin >> k;
        rep(j,k) {
            int s;
            cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }
    int p = 0;
    rep(i,m) {
        int P;
        cin >> P;
        p |= P<<i;
    }
    int ct = 0;
    rep(i,1<<n) {
        int t = 0;
        rep(j,n) {
            if (i>>j&1) t ^= a[j];
        }
        if (p == t) ct++;
    }
    cout << ct << endl;
}