#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i, j, m, sk;
  cin >> n >> m;
  int s[m][n];
  int k[m];
  int num[m];
  int truecount = 0;
  for (i = 0; i < m; i++) {
    num[i] = i;
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  int p[m];
  for (i = 0; i < m; i++) {
    cin >> p[i];
  }
  int scount;
  int result = 0;
  bool flag = true;
  for (int snum = 0; snum < (int)(pow(2, n)); snum++) {
    flag = true;
    for (j = 0; j < m; j++) {
      scount = 0;
      for (sk = 0; sk < k[j]; sk++) {
        scount += snum % ((int)(pow(2, s[j][sk])));
      }
      if (scount % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag == true) {
      result += 1;
    }
  }
  result = result / 2;
  cout << result;
  return 0;
}
