#include <bits/stdc++.h>
using namespace std;
template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
using vector3 = vector<vector2<T>>;
template <typename T>
using vector4 = vector<vector3<T>>;
using lint = long long;
int bitCount(int 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 N, M;
  cin >> N >> M;
  vector<int> S(M, 0);
  for (lint i = 0; i < (M); ++i) {
    int K;
    cin >> K;
    for (lint j = 0; j < (K); ++j) {
      int I;
      cin >> I;
      S[j] = S[j] | (1 << (I - 1));
    }
  }
  vector<int> P(M);
  for (lint i = 0; i < (M); ++i) {
    cin >> P[i];
  }
  int count = 0;
  for (lint i = 0; i < (pow(2, N)); ++i) {
    bool allTentou = true;
    for (lint j = 0; j < (M); ++j) {
      if (bitCount(i & S[j]) % 2 != P[j]) {
        allTentou = false;
        break;
      }
    }
    if (allTentou) {
      count++;
    }
  }
  cout << count << endl;
}
