#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
 
    int n, m;
    cin >> n >> m;
 
    vector<vector<int>> s(m);
    vector<int> k(m);
    for(int i = 0; i < m; ++i){
        cin >> k[i];
        vector<int> sk(k[i]);
        for(int j = 0; j < k[i]; ++j) cin >> sk[j];
 
        s[i] = sk;
    }

    vector<int> p(m);
    for(int i = 0; i < m; ++i) cin >> p[i];
 
    int res = 0;
    for(int i = 0; i < (1<<n); ++i){
        vector<int> on(n, 0);
        for(int j = 0; j < n; ++j){
            if(i & (1<<j)) on[j] = 1;
        }
 
        bool all_on = true;
        for(int j = 0; j < m; ++j)){
            int on_num = 0;
            for(int l = 0; l < k[j]; ++l){
                if(on[s[j][l] - 1]) ++on_num;
            }
 
            if(on_num%2 != p[j]) {
                all_on = false;
                break;
            }
        }
        
        if(all_on) ++res;
    }
 
    cout << res << endl;
 
    return 0;
}