#include <bits/stdc++.h>
using namespace std;
int A(int x) {
  if (x >= 0)
    return x;
  else
    return -x;
}
long long inv(long long x) {
  long long res = 1;
  long long k = (1000000000 + 7) - 2;
  long long y = x % (1000000000 + 7);
  while (k) {
    if (k & 1) res = (res * y) % (1000000000 + 7);
    y = (y % (1000000000 + 7)) * (y % (1000000000 + 7)) % (1000000000 + 7);
    k /= 2;
  }
  return res;
}
unsigned long long popCount64bitB(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) + (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) + (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) + (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) + (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) + (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) + (x & 0x00000000ffffffffUL);
  return x;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> light(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    light[i] = 0;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      light[i] += (1 << (s - 1));
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < (1 << n); i++) {
    bool flag = true;
    ;
    for (int j = 0; j < m; j++) {
      int digit = i & light[j];
      int num = popCount64bitB(digit);
      if (num % 2 != p[j]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
