#include <cstdio>
using namespace std;
int N, M, k[11], s[11][11], p[11], ans;
int main() {
  scanf("%d %d", &N, &M);
  for(int i = 1; i <= M; ++i) {
    scanf("%d", &k[i]);
    for(int j = 1; j <= k[i]; ++j) scanf("%d", &s[i][j]);
  }
  for(int i = 1; i <= M; ++i) scanf("%d", &p[i]);

  for(int i = 0; i < (1<<N); ++i) {
    bool ok = true;
    for(int j = 1; j <= M; ++j) {
      int cnt = 0;
      for(int m = 1; m <= k[j]; ++m){
        if(i & (1<<(s[j][m]-1))) ++cnt;
      }
      ok &= (cnt%2 == p[j]);
    }
    if(ok) ++ans;
  }
  printf("%d\n", ans);
}