#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main (){
    int n,m;
    cin >> n >> m;
    int k[m];
    bool s[m][n]={};
    int tmp;
    for (int i = 0; i < m; i++){
        cin >> k[i];
        for (int j = 0; j < k[i]; j++){
            cin >> tmp;
            s[i][tmp-1]=true;
        }
    }
    int p[m];
    for (int i = 0; i < m; i++){
        cin >> p[i];
    }

//    cout << "\n";
//    for (int i = 0; i < m; i++){
//        for (int j = 0; j < n; j++){
//            cout << (int)s[i][j] << " ";
//        }
//        cout << "\n";
//    }
//    cout << "\n";

    bool jud;
    int connect;
    int count=0;
    for (int bit = 0; bit < (1<<n); ++bit){
        jud=true;
        for (int i = 0; i < m; i++){
            connect=0;
            for (int j = 0; j < n; j++){
                if(s[i][j] && (bit & (1<<i))) connect++;
            }
            if(connect%2!=p[i] || connect<1) jud=false;
        }
        if(jud) count++;
    }
    cout << count << "\n";
    return 0;
}