#include <bits/stdc++.h>
using namespace std;
int N, M;
int K[10];
int S[10][10];
int P[10];
int Sbits[10];
int numofbits(long bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int(m) = 0; (m) < (int)(M); ++(m)) {
    cin >> K[m];
    for (int(k) = 0; (k) < (int)(K[m]); ++(k)) {
      cin >> S[m][k];
      Sbits[m] |= (1 << S[m][k]);
    }
  }
  for (int(m) = 0; (m) < (int)(M); ++(m)) {
    cin >> P[m];
  }
  int count = 0;
  for (int i = 1; i < pow(2, N); i++) {
    int switches = i << 1;
    int ok = true;
    for (int(m) = 0; (m) < (int)(M); ++(m)) {
      if (numofbits(switches & Sbits[m]) % 2 != P[m]) {
        0 && cout << "[NG] switches = " << bitset<12>(switches)
                  << ", Sbits=" << bitset<12>(Sbits[m]) << endl;
        ok = false;
        break;
      }
    }
    if (ok) {
      0 && cout << "[OK] switches = " << bitset<12>(i) << endl;
      count++;
    }
  }
  cout << dec << count << endl;
  return 0;
}
