#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int a;
      cin >> a;
      s[i].push_back(a);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  int ans = 0;
  for (int is = 0; is < (1 << n); ++is) {
    bool ok = true;
    for (int i = 0; i < (m); ++i) {
      int cnt = 0;
      for (int x : s[i]) {
        if (is >> x & 1) cnt++;
      }
      cnt %= 2;
      if (cnt != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
