#include <bits/stdc++.h>
using namespace std;
long long _abs(long long x) { return (x > 0 ? x : -x); }
long long ans;
int n, m, k, x, p[11];
vector<int> s[12];
void solve(int i, vector<bool> v) {
  if (i == n) {
    int c = 0;
    bool ok = 1;
    for (int i = 0; i < m; i++) {
      for (int j : s[i]) {
        if (v[j]) c++;
      }
      if (c % 2 != p[i]) ok = 0;
    }
    if (ok) ans++;
    return;
  }
  v.push_back(0);
  solve(i + 1, v);
  v.pop_back();
  v.push_back(1);
  solve(i + 1, v);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> x;
      x--;
      s[i].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  solve(0, {});
  cout << ans << endl;
}
