#include <bits/stdc++.h>
using namespace std;
int state;
inline int val(int pos) { return state & (1 << (pos - 1)); }
int main() {
  int N, M, map[10][10], p[10];
  memset(map, 0, sizeof(map));
  cin >> N >> M;
  int MAXS = (1 << N);
  int k;
  for (int i = 0; i < M; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) cin >> map[i][j];
  }
  for (int i = 0; i < M; ++i) cin >> p[i];
  int ans = 0;
  for (; state < MAXS; ++state) {
    bool flag = true;
    for (int i = 0; i < M; ++i) {
      int num = 0;
      for (int j = 0; map[i][j] != 0; ++j) num = num + (val(map[i][j]) ? 1 : 0);
      if (num % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ++ans;
  }
  cout << ans;
  system("pause");
  return 0;
}
