#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, t, t2, c = 0;
  scanf("%d%d", &N, &M);
  vector<vector<int>> s(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    scanf("%d", &t);
    for (int i2 = 0; i2 < t; i2++) {
      scanf("%d", &t2);
      s[i].push_back(t2 - 1);
    }
  }
  for (int i = 0; i < M; i++) scanf("%d", &p[i]);
  int len = (int)pow(2, N), count, flag;
  for (int i = 0; i < len; i++) {
    flag = 1, count = 0;
    for (int i2 = 0; i2 < M; i2++) {
      for (int i3 = 0; i3 < s[i2].size(); i3++) {
        (i & (1 << s[i2][i3])) != 0 && count++;
      }
      if (count % 2 != p[i2]) {
        flag = 0;
        break;
      }
    }
    if (flag) c++;
  }
  printf("%d", c);
  return 0;
}
