#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > t(m);
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      t[i].push_back(s);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int sum = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < m; j++) {
        if (bit & (1 << t[i][j])) cnt++;
      }
      if (cnt % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) sum++;
  }
  cout << sum << endl;
  return 0;
}
