#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  vector<vector<int>> s(100, vector<int>(100));
  for (int i = 0; i < (m); i++) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); j++) {
      cin >> s[i][j];
    }
  }
  vector<int> p(n);
  for (int i = 0; i < (m); i++) {
    cin >> p[i];
  }
  vector<int> rope_flg(10);
  for (int i = 0; i < (m); i++) {
    for (int j = 0; j < (k[i]); j++) {
      rope_flg[i] |= (1 << k[j] - 1);
    }
  }
  int switch_flg = 0b0000000000;
  int tmp;
  int count = 0;
  int ans = 0;
  for (int i = 0; i < (pow(2, m) - 1); i++) {
    for (int j = 0; j < (m); j++) {
      tmp = rope_flg[j] & i;
      if (__builtin_popcount(tmp) % 2 == p[j]) {
        count++;
      }
    }
    if (count == m) {
      ans++;
    }
  }
  cout << ans << endl;
}
