#include <bits/stdc++.h>
using namespace std;
int bitCount(int bits) {
  int c = bits - ((bits >> 1) & 0x0055);
  c = (c & 0x0333) + ((c >> 2) & 0x0033);
  c = (c + (c >> 4)) & 0x0f0f;
  c = c + (c >> 8);
  return c;
}
int main() {
  long long n, m;
  vector<int> p, s;
  long long k, ts;
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    cin >> k;
    long long tts = 0b0;
    for (int j = 0; j < (k); j++) {
      cin >> ts;
      tts |= (1 << (ts - 1));
    }
    s.push_back(tts);
  }
  for (int i = 0; i < (m); i++) {
    int tp;
    cin >> tp;
    p.push_back(tp);
  }
  long long count = 0;
  for (int i = 0; i < (pow(2, n)); i++) {
    long long t;
    bool ok = true;
    for (int j = 0; j < (n); j++) {
      t = bitCount(i & s[j]);
      if (t % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) count++;
  }
  cout << count << endl;
  return 0;
}
