#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(b),e(b);
  int d[20][20];
  rep(i,b){
  cin>>c[i];
    rep(j,c[i])
      cin>>d[i][j];
  }
  rep(i,b)
    cin>>e[i];
  int ans=0;
  rep(i,(1<<a)){
  bitset<10> bit(a);
  bitset<b> t(0);
    rep(j,b){
    int p=0;
      rep(k,c[j]){
      if(bit[d[j][k]-1])
        p++;
        }
      if(p%2==e[j])
        t.set(j);
    }
    if(bit.all())
    ans++;
  }
  cout<<ans<<endl;
}