#include <bits/stdc++.h>
using namespace std;
long long int light[20] = {0}, a[20];
vector<long long int> v[20];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, ans = 0, k, x;
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    cin >> k;
    for (long long int j = 0; j < k; j++) {
      cin >> x;
      v[x - 1].push_back(i);
    }
  }
  for (long long int i = 1; i <= m; i++) cin >> a[i];
  for (long long int mask = 1; mask < (1 << n); mask++) {
    memset(light, 0, sizeof(light));
    for (long long int i = 0; i < n; i++) {
      if ((mask & (1 << i))) {
        for (long long int j = 0; j < v[i].size(); j++) {
          light[v[i][j]]++;
        }
      }
    }
    long long int f = 1;
    for (long long int i = 1; i <= m; i++) {
      if (light[i] % 2 == a[i])
        continue;
      else {
        f = 0;
        break;
      }
    }
    ans += f;
  }
  cout << ans << endl;
}
