#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef HOME
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define me(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int>k[m];
    for(int i=0;i<m;i++){
        int kk;
        cin>>kk;
        while(kk--){
            int num;
            cin>>num;
            num--;
            k[i].push_back(num);
        }
    }
    vector<int>p;
    for(int i=0;i<m;i++){
        int num;
        cin>>num;
        p.push_back(num);
    }
    int count=0;
    for(int i=1;i<(1<<n);i++){
        //vector<int>temp;
        set<int>s;
        for(int j=0;j<m;j++){
            if(i&1<<j){
                // temp.push_back(i);
                s.insert(j);
            }
        }
        debug()<<me(s);
        int mk=0;
        for(int l=0;l<m;l++){
            debug()<<me(k[l]);
            int c=0;
            for(int o=0;o<k[l].size();o++){
                if(s.find(k[l][o])!=s.end()){
                    c++;
                }
            }
            int t=p[l];
            if(c%2==t){
                mk++;
            }
        }
        debug()<<me(mk);
        if(mk==m){
            count++;
        }
        //int size=temp.size();
    }
    cout<<count<<endl;
    
    return 0;
    
}

