#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int G[15][15];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < int(M); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < int(k); ++j) {
      int s;
      cin >> s;
      s--;
      G[s][i] = 1;
    }
  }
  vector<int> p(M);
  for (int i = 0; i < int(M); ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    cerr << bitset<10>(bit) << endl;
    vector<int> q(M, 0);
    for (int i = 0; i < N; ++i) {
      if ((bit >> i) & 1) {
        cerr << "i: " << i << endl;
        for (int j = 0; j < int(M); ++j) {
          if (G[i][M - 1 - j] == 1) {
            cerr << "i,j: " << i << " " << M - 1 - j << endl;
            q[j] += 1;
            q[j] %= 2;
          }
        }
      }
    }
    int cnt = 0;
    {
      cerr << "p"
           << ": [ ";
      for (auto _ : p) cerr << _ << ", ";
      cerr << "]" << endl;
    };
    {
      cerr << "q"
           << ": [ ";
      for (auto _ : q) cerr << _ << ", ";
      cerr << "]" << endl;
    };
    for (int j = 0; j < int(M); ++j) {
      if (p[j] == q[j]) cnt++;
    }
    cerr << "cnt: " << cnt << endl;
    if (cnt == M) ans++;
  }
  cout << ans << endl;
}
