#include <bits/stdc++.h>
using namespace std;
unsigned long long inf = (1LL << 62);
long long MOD = (long long)pow(10.0, 9.0) + 7;
pair<long long, long long> dx[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char da[4] = {'R', 'L', 'D', 'U'};
char dax[4] = {-1, 1, -1, 1};
char dax2[4] = {1, -1, 1, -1};
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long max(long long a, long long b) { return (a > b) ? a : b; }
vector<long long> conlist[100];
long long p[1000];
long long dfs(string state, int all, int M) {
  long long retval = 0, sum = 0;
  if (state.length() == all) {
    for (int i = 0; i < (int)(M); i++) {
      for (int j = 0; j < (int)(conlist[i].size()); j++) {
        sum += (state[conlist[i][j]] == '1');
      }
      if (sum % 2 != p[i]) {
        return 0;
      }
      sum = 0;
    }
    return 1;
  } else {
    retval = dfs(state + "0", all, M) + dfs(state + "1", all, M);
  }
  return retval;
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    long long k, s;
    cin >> k;
    for (int i = 0; i < (int)(k); i++) {
      cin >> s;
      s--;
      conlist[i].push_back(s);
    }
  }
  for (int i = 0; i < (int)(m); i++) {
    cin >> p[i];
  }
  cout << dfs("", n, m) << endl;
  return 0;
}
