#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > s(m);
  vector<long long> k(m);
  vector<long long> p(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      long long a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  long long ans = 0;
  for (long long bit = 0; bit < (1 << n); bit++) {
    vector<long long> cnt(n, 0);
    for (int j = 0; j < n; j++) {
      if (bit & (1 << j)) {
        cnt[j]++;
      }
    }
    vector<long long> count(m, 0);
    for (int a = 0; a < n; a++) {
      for (int b = 0; b < k[a]; b++) {
        count[a] += cnt[s[a][b]];
      }
    }
    bool flag = true;
    for (int x = 0; x < m; x++) {
      if (count[x] % 2 == p[x]) {
        flag = true;
      } else {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
