#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7, INF = 1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> p(m);
  for (int i = 0; i < (m); i++) {
    int k;
    cin >> k;
    v[i].resize(k);
    for (int j = 0; j < (k); j++) {
      cin >> v[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < (m); i++) cin >> p[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    bool f = true;
    for (int i = 0; i < (m); i++) {
      int cnt = 0;
      for (int j = 0; j < (v[i].size()); j++) {
        if (bit & (1 << j)) cnt++;
      }
      if (cnt % 2 != p[i]) f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
  system("pause");
}
