#include <bits/stdc++.h>
using namespace std;
int X = 0;
int N, M, k[30], s[30][30];
bool p[30];
int ans = 0;
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  while (!(X & (1 << N))) {
    bool a = true;
    for (int i = 0; i < M; i++) {
      bool b = true;
      for (int j = 0; j < k[i]; j++) {
        b = b ^ (!(X & (1 << s[i][j] - 1)));
      }
      a = a && (b == p[i]);
      if (!a) break;
    }
    if (a) ans++;
    X++;
  }
  cout << ans;
}
