#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> a(11);
long long ch[11], n, m, ans;
bool sw[11];
void cal() {
  bool now = true;
  for (long long i = 0; i < n; i++) {
    long long sum = 0;
    for (long long j = 0; j < a[i].size(); j++) {
      if (sw[a[i][j]]) {
        sum++;
      }
    }
    if (sum % 2 != ch[i]) {
      now = false;
    }
  }
  if (now != false) {
    ans++;
  }
}
void dep(long long now) {
  if (now == n) {
    cal();
    return;
  }
  sw[now] = 0;
  dep(now + 1);
  sw[now] = 1;
  dep(now + 1);
}
int main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x;
    cin >> x;
    for (long long j = 0; j < x; j++) {
      long long y;
      cin >> y;
      y--;
      a[i].push_back(y);
    }
  }
  for (long long i = 0; i < n; i++) {
    cin >> ch[i];
  }
  dep(0);
  cout << ans;
  return 0;
}
