#include <bits/stdc++.h>
using namespace std;
int s[11][11];
int k[11];
int p[11];
int on[11];
int main() {
  int n, m, num, ans = 0;
  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];
  bool ok;
  for (int bit = 0; bit < (1 << n); ++bit) {
    for (int i = 0; i < n; i++) on[i] = 0;
    ok = true;
    num = 0;
    for (int i = 0; i < n; i++)
      if (bit & (1 << i)) on[i] = 1;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < k[i]; j++)
        if (on[s[i][j]]) num++;
      if (num % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
