#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> data(10, vector<int>(10));
  vector<int> amari(10);
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int a;
      cin >> a;
      data[i][a - 1] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> amari[i];
  }
  int bit;
  int ans = 0;
  for (bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    vector<int> on(10);
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        on[i] = 1;
      }
    }
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        if (data[i][j]) {
          cnt += on[i];
        }
      }
      if (cnt % 2 != amari[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans / 2 << endl;
}
