#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vv(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int h;
      cin >> h;
      vv[i].push_back(--h);
    }
  }
  vector<int> swi(m);
  for (auto& x : swi) cin >> x;
  int ret = 0;
  for (int i = 0; 1 << n; i++) {
    bool flag = true;
    for (int j = 0; j < m; j++) {
      int on = 0;
      for (const auto& x : vv[j]) {
        if (i >> x & 1) on++;
      }
      if (on % 2 != swi[j]) flag = false;
    }
    if (flag) ret++;
  }
  cout << ret << endl;
}
