#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int mod = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
long power(long a, long b) {
  return b ? power(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      s--;
      a[s] |= 1 << j;
    }
  }
  int p = 0;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    p |= x << i;
  }
  int ans = 0;
  for (int s = 0; s < (1 << n); ++s) {
    int t = 0;
    for (int i = 0; i < n; ++i) {
      if (s >> i & 1) {
        t ^= a[i];
      }
    }
    if (t == p) ans++;
  }
  cout << ans << endl;
}
