#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      a.at(i).push_back(s);
    }
  }
  vector<int> p(m);
  for (auto x : p) cin >> x;
  int count = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool flag = true;
    for (int j = 0; j < m; j++) {
      int l = 0;
      for (int k = 0; k < a.at(j).size(); k++) {
        if (i & (1 << (a.at(j).at(k) - 1))) l++;
      }
      if (l % 2 == p.at(j) % 2) {
        flag = false;
        break;
      }
    }
    if (flag) count++;
  }
  cout << count << endl;
}
