#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vec(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      vec[i].push_back(x);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int count = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vector<int> on;
    bool flag = true;
    for (int j = 0; j < m; ++j) {
      int con = 0;
      for (int v : vec[j]) {
        if (bit & (1 << v)) ++con;
      }
      if (con % 2 != p[j]) flag = false;
    }
    if (flag) ++count;
  }
  cout << (count) << endl;
  return 0;
}
