#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<int>;
const int INF = 2147483647;
const ll MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s;
  s.resize(m);
  for (int i = 0; i < m; ++i) {
    int k = 0;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int swt = 0;
      cin >> swt;
      --swt;
      s[i].emplace_back(swt);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 1; bit < (1 << n); ++bit) {
    bool judge = true;
    for (int i = 0; i < m; ++i) {
      int swt = 0;
      for (auto j : s[i]) {
        if (bit & (1 << j)) {
          ++swt;
        }
      }
      if ((swt % 2 != p[i])) {
        judge = false;
        break;
      } else {
      }
    }
    if (judge) {
      ++ans;
    }
  }
  cout << ans;
}
