#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long N = 200005;
const long long inf = 10000000000000000;
void print(vector<long long> v) {
  long long i;
  for (i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
vector<long long> read(long long n) {
  long long i;
  vector<long long> arr(n, 0);
  for (i = 0; i < n; i++) cin >> arr[i];
  return arr;
}
vector<long long> read(long long n, long long k) {
  long long i;
  vector<long long> arr(n + k, 0);
  for (i = k; i < n + k; i++) cin >> arr[i];
  return arr;
}
bool isEven(long long n) { return n % 2 == 0; }
bool isOdd(long long n) { return n % 2 == 1; }
void solve() {
  long long t;
  cin >> (t);
  while (t--) {
    long long i, j, k, n, m, p, q, x, y, a, b, l, r;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j, k, n, m, q, x, y, a, b, l, r;
  cin >> n >> m;
  vector<long long> adj[m];
  for (i = 0; i < m; i++) {
    cin >> k;
    for (j = 0; j < k; j++) {
      cin >> x;
      x--;
      adj[i].push_back(x);
    }
  }
  vector<long long> p;
  p = read(n);
  long long mask = 0;
  long long ans = 0;
  for (mask = 0; mask < (1 << n); mask++) {
    bool ok = 1;
    for (i = 0; i < m; i++) {
      long long ct = 0;
      for (auto on : adj[i]) {
        if (mask & (1 << on)) {
          ct++;
        }
      }
      if (ct % 2 != p[i] % 2) {
        ok = 0;
      }
    }
    if (ok) ans++;
  }
  cout << ans;
  return 0;
}
