#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const long long INFL = 1LL << 60;
const int INF = 1 << 29;
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  vector<int> K(M);
  vector<vector<int> > S(N, vector<int>(N));
  for (int i = 0; i < M; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> S[i].at(j);
      S[i].at(j)--;
    }
  }
  vector<int> pair<int, int>(M);
  for (int i = 0; i < M; i++) {
    cin >> pair<int, int>[i];
  }
  for (int i = 0; i < (1 << N); i++) {
    int flag = 1;
    for (int j = 0; j < M; j++) {
      bool tmp = i & (1 << S[j].at(0));
      for (int k = 1; k < K[j]; k++) {
        tmp = tmp ^ (i & (1 << S[j].at(k)));
      }
      if (tmp != pair<int, int>[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
