#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(M));
  vector<int> p(M);
  for (int(i) = (0); (i) < (M); ++(i)) {
    cin >> k[i];
    for (int(j) = (0); (j) < (k[i]); ++(j)) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int(i) = (0); (i) < (M); ++(i)) cin >> p[i];
  int ans = 0;
  for (int(mask) = (0); (mask) < (1 << N); ++(mask)) {
    bool flag = true;
    for (int(i) = (0); (i) < (M); ++(i)) {
      int x = 0;
      for (int(j) = (0); (j) < (k[i]); ++(j)) {
        if (mask & (1 << s[i][j])) ++x;
      }
      if (x % 2 == p[i])
        continue;
      else {
        flag = false;
        break;
      }
    }
    if (flag) ++ans;
  }
  cout << ans << endl;
  return 0;
}
