#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = INT_MAX;
int a[30];
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  int s[20][20];
  for (int i = 0; i < (M); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) cin >> s[i][j];
  }
  vector<int> p(M);
  for (int i = 0; i < (M); ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    bool flag = true;
    vector<int> sum(M);
    for (int i = 0; i < (M); ++i) sum[i] = 0;
    for (int i = 0; i < M; ++i) {
      if (bit & (1 << i)) {
        for (int j = 0; j < k[i]; ++j) {
          ++sum[s[i][j] - 1];
        }
      }
    }
    for (int i = 0; i < (M); ++i) {
      if (sum[i] % 2 != p[i]) flag = false;
    }
    if (flag) ++ans;
  }
  cout << ans << endl;
  ;
  return 0;
}
