#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> data(M, vector<int>(11));
  for (int i = 0; i < (M); ++i) {
    int temp;
    cin >> temp;
    for (int j = 0; j < (temp); ++j) cin >> data.at(i).at(j);
  }
  vector<int> C(M);
  for (int i = 0; i < (M); ++i) cin >> C.at(i);
  int ans;
  ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    bitset<11> bs(i);
    int count;
    count = 0;
    for (int j = 0; j < (M); ++j) {
      int k;
      k = 0;
      while (k < 11 && data.at(j).at(k) != 0) {
        if (bs.test(data.at(j).at(k) - 1)) count++;
        k++;
      }
      if (count % 2 != C.at(j)) break;
      if (j == M - 1) ans++;
    }
  }
  cout << ans << endl;
}
