#include <bits/stdc++.h>
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
const int INF = 1e9;
int guki(int a) {
  if (a % 2 == 0)
    return 0;
  else
    return 1;
}
int gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) {
  int x = gcd(a, b);
  return (a * b / x);
}
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<vector<int>> vec(m);
  for (int i = (int)(0); i < (int)(m); ++i) {
    int a;
    cin >> a;
    vec[i].resize(a);
    for (int j = (int)(0); j < (int)(a); ++j) {
      cin >> vec[i][j];
      vec[i][j]--;
    }
  }
  vector<int> h(m);
  for (int i = (int)(0); i < (int)(m); ++i) {
    cin >> h[i];
  }
  for (int i = (int)(0); i < (int)((1 << n)); ++i) {
    vector<int> b(n);
    for (int j = (int)(0); j < (int)(m); ++j) {
      if (i & (1 << j)) {
        b[j] = true;
      }
    }
    bool fl = true;
    for (int k = (int)(0); k < (int)(m); ++k) {
      int cnt = 0;
      for (int l = (int)(0); l < (int)(vec[k].size()); ++l) {
        if (b[vec[k][l]]) cnt++;
      }
      if (cnt % 2 != h[k]) fl = false;
    }
    if (fl) ans++;
  }
  cout << ans << endl;
}
