#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"(n,m),*s,p=[list(map(int,t.split()))for t in open(0)]\n"
"a=0\n"
"for i in range(1<<n):\n"
" c=[0]*m\n"
" for j in range(n*m):c[j%m]^=i>>j//m&(j//m+1in s[j%m][1:])\n"
" a+=c==p\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            