#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int k, s;
  vector<vector<int> > v(m);
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> k;
    for (int(j) = 0; (j) < (k); (j)++) {
      cin >> s;
      v[i].push_back(s);
    }
  }
  vector<int> p(m);
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> p[i];
  }
  int ans = 0, flg;
  vector<bool> light(m);
  for (int(i) = 0; (i) < (1 << n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) light[j] = 0;
    for (int(j) = 0; (j) < (m); (j)++) {
      for (int(k) = 0; (k) < (v[j].size()); (k)++) {
        if ((i | (1 << k)) == i) {
          light[j] = !light[j];
        }
      }
    }
    flg = 1;
    for (int(j) = 0; (j) < (m); (j)++) {
      if (light[j] != p[j]) flg = 0;
    }
    if (flg) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
