#include <bits/stdc++.h>
using namespace std;
long long n, m, p[100], ans, sz[100];
vector<long long> s[100];
int main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> sz[i];
    for (long long j = 0; j < sz[i]; j++) {
      long long b;
      cin >> b;
      s[j].push_back(b);
    }
  }
  for (long long i = 0; i < m; i++) cin >> p[i];
  for (long long i = 0; i < 1ll << n; i++) {
    bool on[110] = {}, ok = true;
    for (long long j = 0; j < n; j++)
      if (i & (1ll << j)) on[j] = true;
    for (long long j = 0; j < m; j++) {
      long long now = 0;
      for (long long k = 0; k < s[j].size(); k++) {
        if (on[s[j][k] - 1]) now++;
      }
      if (now % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
