#include <bits/stdc++.h>
using namespace std;
bool pairCompare(const pair<int, int>& firstElof,
                 const pair<int, int>& secondElof) {
  return firstElof.first > secondElof.first;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  int ktmp, stmp;
  vector<vector<int>> s(m, vector<int>(n, -1));
  vector<int> k(m);
  vector<int> p(m);
  for (int im = 0; im < m; im++) {
    cin >> ktmp;
    k.at(im) = ktmp;
    for (int iktmp = 0; iktmp < ktmp; iktmp++) {
      cin >> stmp;
      stmp--;
      s.at(im).at(stmp) = 1;
    }
  }
  for (int im = 0; im < m; im++) {
    cin >> p.at(im);
  }
  int modulo, ans = 0;
  bool flg;
  for (int isw = 0; isw < (1 << n); isw++) {
    modulo = 0;
    flg = true;
    for (int im = 0; im < m; im++) {
      for (int in = 0; in < n; in++) {
        if (s.at(im).at(in) == -1) continue;
        modulo += (isw >> in) & s.at(im).at(in);
      }
      if (modulo % 2 != p.at(im)) {
        flg = false;
        break;
      }
    }
    if (flg) ans++;
  }
  cout << ans << endl;
  return (0);
}
