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