#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> light(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 s;
      cin >> s;
      light[i] |= (1 << s);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int b = 0; b < (1 << n); b++) {
    bool can = true;
    for (int i = 0; i < m; i++) {
      int cnt = __builtin_popcount(b & light[i]);
      if (cnt % 2 != p[i]) can = false;
    }
    if (can) ans++;
  }
  cout << ans << '\n';
}
