#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  vector<vector<int> > bulbs;
  vector<int> p;
  cin >> N >> M;
  bulbs.assign(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      bulbs[i].push_back(s - 1);
    }
  }
  for (int i = 0; i < M; i++) {
    int pi;
    cin >> pi;
    p.push_back(pi);
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << N); mask++) {
    bool isOn = true;
    for (int i = 0; i < M; i++) {
      int onCount = 0;
      for (int j = 0; j < (int)bulbs[i].size(); j++) {
        if (mask & (1 << bulbs[i][j])) onCount++;
      }
      isOn &= (onCount % 2 == p[i]);
    }
    ans += (isOn ? 1 : 0);
  }
  cout << ans << endl;
  return 0;
}
