#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<string,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
bool pairCompare2(P firstElof,P secondElof){
    return (firstElof.second)%1000>(secondElof.second)%1000;
}
bool less_mod1000(int lhs, int rhs) {
  if ((lhs - rhs) % 1000 != 0)
    return lhs % 1000 < rhs % 1000;
  else // 5で割った余りが等しいなら普通に大小比較する
    return lhs < rhs;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    ll k[m];
    ll in;
    vector<pair<vector<ll>,ll>> vec;
    rep(i,0,m){
        cin>>k[i];
        rep(j,0,k[i]){
            vec.first[j].push_back(cin>>in);
        }
    }
    rep(i,0,m)cin>>vec[i].second.push_back(cin>>in);
    ll memo=0;
    bool flag=true;
    ll ans=0;
    rep(i,0,1024){
        rep(j,0,m){
            memo=0;
            rep(l,0,k[j]){
                if(i&(1<<vec[j].first[l]))memo++;
            }
            if(memo%2!=vec[j].second)flag=false;
        }
        if(flag)ans++;
        flag=true;
    }
    cout<<ans<<endl;
}
