#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  bool s[10][10];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int x;
      cin >> x;
      x--;
      s[i][x] = true;
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<int> a;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) a.push_back(j);
    bool bb = true;
    for (int j = 0; j < m; j++) {
      int tmp = 0;
      for (int l = 0; l < a.size(); l++) {
        if (s[j][a[l]]) tmp++;
      }
      if (tmp % 2 != p[j]) bb = false;
    }
    if (bb) ans++;
  }
  cout << ans << endl;
  return 0;
}
