#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n);
  for (long long i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      int a;
      cin >> a;
      a--;
      s[a] |= 1 << i;
    }
  }
  int x, p = 0;
  for (long long i = m - 1; 0 <= i; i--) {
    cin >> x;
    p |= x << i;
  }
  int ans = 0;
  for (int S = 0; S < (1 << n); S++) {
    int t = 0;
    for (long long i = 0; i < n; i++) {
      if (S >> i & 1) {
        t ^= s[i];
      }
    }
    if (p == t) {
      ans++;
    }
  }
  cout << ans;
}
