#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(m, vector<int>());
  rep(i, m){
    int k;
    cin >> k;
    rep(j, k) cin >> s.at(i).at(j);
  }
  vector<int> p(m);
  rep(i, m) cin >> p.at(i);

  int ans = 0;
  rep(tmp, 1<<n){
    bitset<n> bs(tmp);
    rep(i, m){
      int cnt = 0;
      for(int x : s.at(i)){
        if(bs.test(x-1)) cnt++;
      }
      if(cnt%2 != p.at(i)) break;
      if(i == m-1) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
