#include <bits/stdc++.h>
using namespace std;
int s[100010] = {};
int p[100010] = {};
vector<int> v[100010];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      s--;
      v[i].push_back(s);
    }
  }
  for (int i = 0; i < M; ++i) {
    scanf("%d", p + i);
  }
  int ans = 0;
  for (int i = 0; i < 1 << N; ++i) {
    int on = 0;
    bool ok = true;
    for (int j = 0; j < M; ++j) {
      for (int k : v[j]) {
        if (i >> k & 1) on++;
      }
      if (!((p[j] == 0 && on % 2 == 0) || (p[j] == 1 && on % 2 == 1))) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
