#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
struct ed {
    double x; 
    double y;  
    double l; 
    double a;
};

int main() {
  int n,m,k,x;
  cin >> n >> m;
  vvi s(m);
  vi p(m);
  REP(i,m) {
    cin >> k;
    REP(j,k) {
      cin >> x;
      x--;
      s[i].insert(x);
    }
  }
  REP(i,m) cin >> p[i];
  int cnt=0;
  REP(i,pow(2,n)) {
    int c=0;
    REP(j,m) {
      int ktemp=0;
      for(auto k:s[j]) {
        if((i&1<<k)==1) ktemp++;
      }
      if(ktemp%2==p[j]) c++;
    }
    if(c==m) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
