#include <bits/stdc++.h>
using namespace std;
static const long long maxLL = (long long)1 << 62;
const long long MOD = 1000000007, INF = 1e18;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(m, vector<int>(m, 0));
  vector<int> p(m, 0);
  set<int> sw;
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      cin >> s[i][j];
      sw.insert(s[i][j]);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << *max_element(sw.begin(), sw.end())); ++bit) {
    bool is_cnt_up = true;
    for (int j = 0; j < m; ++j) {
      int on_num = 0;
      for (int k = 0; k < s[j].size(); ++k) {
        if ((bit >> (s[j][k] - 1)) & 1) on_num++;
      }
      if (on_num == 0) is_cnt_up = false;
      if (on_num % 2 != p[j]) is_cnt_up = false;
    }
    if (is_cnt_up) ans++;
  }
  cout << ans << endl;
}
