y#include<bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  int cnt[m][n]; rep(i, m) rep(j, n) cnt[i][j] = 0;
  
  rep(i, m) {
    int k; cin >> k;
    rep(j, k) {
      int x; cin >> x;
      ++cnt[i][x-1];
    }
  }
  int p[m]; rep(i, m) cin >> p[i];
  int ans = 0;

  rep(i, (1<<n)) {
    vector<int> v(n);
    rep(j, n) {
      v[j] = (i>>j & 1);
    }
    bool flag = 1;
    rep(j, m) {
      int sum = 0;
      rep(k, n) {
        sum += (cnt[j][k] * v[k]);
      }
      if(sum%2 != p[j]) flag = 0;
    }
    ans += flag;
  }
  cout << ans;
}
    
