#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> connection(m, vector<int>(0));
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int a;
      cin >> a;
      --a;
      connection[i].push_back(a);
    }
  }
  vector<int> p(m);
  for (int l = 0; l < m; ++l) cin >> p[l];
  int ans = 0;
  bool ok = true;
  for (int i1 = 0; i1 < (1 << n); ++i1) {
    bitset<10> bs(i1);
    int cnt = 0;
    for (int i = 0; i < m; ++i) {
      for (int j : connection[i])
        if (bs.test(j)) cnt++;
      if (cnt % 2 == p[i])
        ok = true;
      else {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
