int main() {
 int a;
 int b;
  cin >> a >> b;
  int y = 0;
  vector<vector<int>> d(b);
  for(int i=0;i < b;i++){
    int z;
     cin >> z;
     int k = 0;
     for(int j=0;j<z;j++){
       int rrr;
       cin >> rrr;
          d.at(i).push_back(rrr-1);}
  }
  vector<int> p(b);
  for(int i=0;i < b;i++){
    cin >> p.at(i);}
  
 for(int bit = 0;bit <(1<<a);++bit){
   int t = 1;
   for(int i=0;i < b;i++){
     int k = 0;
     for(int j=0;j < d.at(i).size();j++){
       if(bit & (1<<d.at(i).at(j))){k++;}
     }
     if(k % 2 != p.at(i)){t = 0;}
   }
   if(t == 1){y++;}
 }
  cout << y << endl;
       

}