#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const long long MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M), p(M);
  vector<vector<int>> s;
  s = vector<vector<int>>(M, vector<int>(N, 0));
  for (int i = 0; i < (int)(M); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) cin >> s[i][j];
  }
  for (int i = 0; i < (int)(M); i++) cin >> p[i];
  int cnt = 0;
  bool chk = true;
  for (long long i = 1; i <= (long long)(pow(2, N) - 1); i++) {
    for (int j = 0; j < (int)(M); j++) {
      int sum = 0;
      for (int l = 0; l < (int)(k[j]); l++) {
        sum +=
            (i / (int)(pow(2, s[j][l] - 1))) - (i / (int)(pow(2, s[j][l]))) * 2;
      }
      if (sum % 2 != p[j]) {
        chk = false;
        break;
      }
    }
    if (chk) cnt++;
    chk = true;
  }
  cout << cnt << endl;
  return 0;
}
