#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int i, j, k, l, tmp, ans, cnt, N, M, cnt2;
int main(void) {
  vector<vector<int>> s;
  vector<int> p;
  scanf("%d %d", &N, &M);
  for (int i = (0); i < (M); ++i) {
    scanf("%d", &k);
    vector<int> t;
    for (int j = (0); j < (k); ++j) {
      scanf("%d", &tmp);
      t.push_back(tmp - 1);
    }
    s.push_back(t);
  }
  for (int i = (0); i < (M); ++i) {
    scanf("%d", &tmp);
    p.push_back(tmp);
  }
  int bit;
  for (int bit = (1); bit < ((1 << N)); ++bit) {
    cnt2 = 0;
    for (int k = (0); k < (M); ++k) {
      cnt = 0;
      for (int l = (0); l < (s.at(k).size()); ++l) {
        if (((1 << s.at(k).at(l)) & bit) > 0) {
          cnt++;
        }
      }
      if ((cnt % 2) == p.at(k)) {
        cnt2++;
      }
    }
    if (cnt2 == M) {
      ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
