#include <bits/stdc++.h>
using namespace std;
int N, M;
int k[12];
int s[12][12];
int p[12];
int q[12];
bool check(int bit) {
  for (int i = 0; i < (M); ++i) q[i] = 0;
  for (int i = 0; i < (N); ++i) {
    if (bit & (1 << i)) {
      for (int j = 0; j < (k[i]); ++j) {
        ++q[s[i][j]];
      }
    }
  }
  for (int i = 0; i < (M); ++i) {
    if (q[i] % 2 != p[i]) return false;
  }
  return true;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < (M); ++i) {
    cin >> k[i];
    for (int j = 0; j < (N); ++j) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  for (int i = 0; i < (M); ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    if (check(bit)) ++ans;
  }
  cout << ans << endl;
  return 0;
}
