#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int kin;
    cin >> kin;
    k.at(i) = kin;
    for (int j = 0; j < kin; j++) {
      int sin;
      cin >> sin;
      s.at(i).push_back(sin);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int pin;
    cin >> pin;
    p.at(i) = pin;
  }
  int bit;
  int count = 0;
  vector<int> on(n);
  for (bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i))
        on.at(i) = 1;
      else
        on.at(i) = 0;
    }
    bool check = true;
    int sum = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < (int)s.at(i).size(); j++)
        sum += on.at(s.at(i).at(j) - 1);
      if (sum % 2 != p.at(i)) {
        check = false;
        break;
      }
    }
    if (check) count++;
  }
  cout << count << endl;
  return 0;
}
