#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  int d[10][10];
  for (int i = 0; i < m; i++) {
    cin >> k.at(i);
    for (int j = 0; j < k.at(i); j++) {
      cin >> d[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p.at(i);
  int ans = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<10> s(tmp);
    int sum = 0;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < k.at(i); j++) {
        if (s.test(d[i][j])) {
          cnt++;
          cout << "yes" << endl;
        }
      }
      if (cnt % 2 == p.at(i)) sum++;
    }
    cout << "sum" << sum << endl;
    if (sum == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
