#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000000000001;
struct edge {
  int to, cost;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
struct Road {
  double cost;
  int a, b;
};
struct pos {
  int x, y, sx, sy, total;
};
int k[11], s[11][11];
int p[11];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[j][i];
    }
  }
  int total = 0;
  for (int i = 0; i < m; ++i) cin >> p[i];
  for (int i = 0; i <= (1 << n); i++) {
    int f = 0;
    for (int l = 0; l < m; ++l) {
      int t = 0;
      for (int j = 0; j < k[l]; ++j) {
        if (i & (1 << (s[j][l] - 1))) t++;
      }
      if (t % 2 != p[l]) {
        f = 1;
        break;
      }
    }
    if (f == 0) total++;
  }
  cout << total << endl;
  return 0;
}
