#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m, vector<int>(10));
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> k[i];
    for (long long j = 0; j < (long long)(k[i]); j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (long long i = 0; i < (long long)(m); i++) cin >> p[i];
  for (long long i = 0; i < (long long)(1 << n); i++) {
    bool jdg = true;
    for (long long j = 0; j < (long long)(m); j++) {
      int cnt = 0;
      for (long long l = 0; l < (long long)(k[m]); l++) {
        if (i & (1 << s[j][l])) {
          cnt++;
        }
      }
      if (cnt % 2 != p[j]) jdg = false;
    }
    if (jdg) ans++;
  }
  cout << ans << endl;
}
