#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  int s[11][11];
  for (int i = 0; i < (M); ++i)
    for (int j = 0; j < (M); ++j) s[i][j] = -1;
  for (int i = 0; i < (M); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  int p[11];
  for (int i = 0; i < (M); ++i) cin >> p[i];
  int sum[11];
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    for (int i = 0; i < (N); ++i) sum[i] = 0;
    for (int j = 0; j < (M); ++j) {
      if (i & (1 << j)) {
        for (int k = 0; k < (M); ++k) {
          for (int l = 0; l < (M); ++l)
            if (s[k][l] == j) sum[k]++;
        }
      }
    }
    bool can = true;
    for (int m = 0; m < (M); ++m) {
      if (sum[m] % 2 != p[m]) can = false;
    }
    if (can) ans++;
  }
  cout << ans << endl;
}
