#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int64_t large = 9223372036854775807;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> list(M, vector<int>());
  int p, q;
  for (int i = 0; i < M; i++) {
    cin >> p;
    list[i].push_back(p);
    for (int j = 0; j < p; j++) {
      cin >> q;
      q--;
      list[i].push_back(q);
    }
  }
  vector<int> amari(M);
  for (int i = 0; i < M; i++) cin >> amari[i];
  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<10> s(tmp);
    vector<int> on(M);
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < list[i][0]; j++) {
        if (s[list[i][j]]) on[i]++;
      }
    }
    bool x = true;
    for (int i = 0; i < M; i++) {
      if (on[i] % 2 != amari[i]) x = false;
    }
    if (x) ans++;
  }
  cout << ans;
}
