#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

int main()
{
  ul n,m;
  cin>>n>>m;

  ul s[10];
  ul p[10];
  fill(s, s + 10, 0);
  fill(p, p + 10, 0);

  ul k,cs;
  for (size_t i = 0; i < m; i++)
  {
    cin>>k;
    for (size_t j = 0; j < k; j++)
    {
      cin>>cs;
      cs--;
      s[i]|=1<<cs;
    }
  }
  for (size_t i = 0; i < m; i++)
  {
    cin>>p[i];
  }

  ul msn=1<<n,cj,ct=0;
  for (ul i = 0; i < msn; i++)
  {
    cj=1;
    for (ul j = 0; j < m; j++)
    {
      //cout<<i<<" "<<s[j]<<" "<<__popcount(i&s[j])<<endl;
      if (__popcount(i & s[j]) % 2 != p[j]) {
        cj=0;
        break;
      }
    }
    ct+=cj;
  }
  cout<<ct<<endl;

  return 0;
}
