#include <bits/stdc++.h>
using namespace std;
int n, m, cnt = 0;
int k[12], p[12], s[12][12], ison[12];
void solve(int num) {
  if (num <= n) {
    ison[num] = 1;
    solve(num + 1);
    ison[num] = 0;
    solve(num + 1);
  } else {
    for (int i = 0; i < m; ++i) {
      int oncnt = 0;
      for (int j = 0; j < k[i]; ++j) {
        if (ison[s[i][j]]) ++oncnt;
      }
      if (oncnt % 2 != p[i]) return;
    }
  }
  ++cnt;
}
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  for (int i = 0; i <= n; ++i) ison[i] = 0;
  solve(1);
  cout << cnt << endl;
}
