#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long long MOD = 1000000007;
const int MAX = 510000;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int num;
      cin >> num;
      s[i].push_back(num);
    }
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  int res = 0;
  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> b(tmp);
    bool OK = true;
    for (int i = 0; i < M; i++) {
      int num2 = 0;
      for (int j = 0; j < k[i]; j++) {
        if (b.test(s[i][j])) num2++;
      }
      if (num2 % 2 != p[i]) {
        OK = false;
        break;
      }
    }
    if (OK) res++;
  }
  res /= pow(2, 10 - N);
  cout << res << endl;
  return 0;
}
