#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m, vector<int>(11));
  vector<int> k(m);
  vector<int> p(m);
  int sum = 0;
  for (int i = 0; i < (m); i++) {
    cin >> k.at(i);
    for (int j = 0; j < (k.at(i)); j++) {
      cin >> s.at(i).at(j);
    }
  }
  for (int i = 0; i < (m); i++) cin >> p.at(i);
  for (int bits = 0; bits < (1 << n); bits++) {
    int ans = 0;
    if (bits == 0) {
      for (int i = 0; i < (m); i++) {
        if (p.at(i) != 0) break;
        if (i == m - 1) ans++;
      }
      continue;
    }
    for (int i = 0; i < (m); i++) {
      int flag = 0;
      for (int j = 0; j < (k.at(i)); j++) {
        if (bits & (1 << (s.at(i).at(j) - 1))) flag++;
      }
      if ((flag % 2) == p.at(i))
        ans++;
      else {
        ans = 0;
        break;
      }
    }
    if (ans == m) sum++;
  }
  cout << sum << endl;
}
