#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
void prtok(bool ok) { cout << (ok ? "yes" : "no") << "\n"; }
int main(void) {
  int n, m;
  cin >> n >> m;
  bool light[m][n];
  for (long long i = (long long)0; i < (long long)n; i++) {
    for (long long j = (long long)0; j < (long long)n; j++) {
      light[i][j] = false;
    }
  }
  for (long long i = (long long)0; i < (long long)m; i++) {
    int num;
    cin >> num;
    for (long long j = (long long)0; j < (long long)num; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      light[i][tmp] = true;
    }
  }
  vector<int> p(m);
  for (long long i = (long long)0; i < (long long)m; i++) {
    cin >> p[i];
  };
  int ans = 0;
  for (long long i = 0; i < (long long)(1 << n); i++) {
    int lightnum = 0;
    for (long long j = (long long)0; j < (long long)m; j++) {
      int on = 0;
      for (long long k = (long long)0; k < (long long)n; k++) {
        if (i & (1 << k)) {
          if (light[j][k]) {
            on++;
          }
        }
      }
      if (on % 2 == p[j]) {
        lightnum++;
      }
    }
    if (lightnum == m) {
      ans++;
    }
  }
  cout << (ans) << "\n";
}
