#include <bits/stdc++.h>
using namespace std;
vector<int> b;
int n, m, ans;
bool check(vector<vector<int>> need, int bit) {
  for (int i = 0; i < m; i++) {
    int cnt = 0;
    for (int j = 0; j < need[i].size(); j++) {
      if (bit & (1 << (need[i][j] - 1))) cnt++;
    }
    if ((cnt & 1) == b[i])
      ;
    else
      return false;
  }
  return true;
}
void solve() {
  cin >> n >> m;
  vector<vector<int>> need(m);
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    for (int j = 0; j < s; j++) {
      int t;
      cin >> t;
      need[i].push_back(t);
    }
  }
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    b.push_back(t);
  }
  for (int bit = 0; bit < (1 << n); ++bit) {
    if (check(need, bit)) {
      ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T_ = 1;
  for (int i = 0; i < T_; i++) solve();
  return 0;
}
