#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
bool dp[(1 << 10) + 5][15];
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> s(m, 0);
  vector<int> p(m);
  for (int i = (0); i < (m); i++) {
    int k;
    cin >> k;
    for (int j = (0); j < (k); j++) {
      int t;
      cin >> t;
      t--;
      s[i] |= (1 << t);
    }
  }
  for (int i = (0); i < (m); i++) cin >> p[i];
  for (int i = (0); i <= (1 << n); i++) {
    dp[i][0] = true;
    for (int j = (0); j < (m); j++) {
      int t = s[j] & i;
      if (__builtin_popcount(t) % 2 == p[j]) dp[i][j + 1] = dp[i][j] & true;
    }
  }
  int ans = 0;
  for (int i = (0); i <= (1 << n); i++)
    if (dp[i][m]) ans++;
  cout << ans << endl;
  return 0;
}
