#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  long long N, M, ans = 0;
  cin >> N >> M;
  long long k[M], p[M], s[M][N];
  bool x[N];
  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];
  }
  for (int(i) = 0; (i) < (1 << N); (i)++) {
    long long count = 0;
    long long count1 = 0;
    for (int(j) = 0; (j) < (N); (j)++) {
      if (i & 1 << j)
        x[j] = true;
      else
        x[j] = false;
    }
    for (int(c) = 0; (c) < (M); (c)++) {
      for (int(l) = 0; (l) < (k[c]); (l)++) {
        if (x[s[c][l] - 1] == true) count++;
      }
      if (count % 2 == p[c]) count1++;
    }
    if (count1 == M) ans++;
  }
  cout << ans;
}
