#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int N, M;
  int s[10][10];
  int k[10], p[10];
  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];
  int ans = 0, num;
  bool flag;
  for (int ind = 0; ind < 1 << (N - 1); ind++) {
    flag = true;
    for (int m = 0; m < M; m++) {
      num = 0;
      for (int i = 0; i < k[m]; i++) {
        if (ind & (1 << (s[m][i] - 1)) == (1 << (s[m][i] - 1))) num++;
      }
      if (num % 2 != p[m]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
