#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  rep(i,m) {
    int k;
    cin >> k;
    rep(j,k) {
      int a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  int p[m];
  rep(i,m) cin >> p[i];
  int ans = 0;
  rep(i,1<<n) {
    int c = 0;
    rep(j,m) {
      int d = 0;
      for(auto q : s[j]) {
        if(i & (1<<q)) d++;
      }
      if(d % 2 == p[j]) c++;
    }
    if(c == m) ans++;
  }
  cout << ans << endl;
  return 0;
}