#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    
    int k[M];
    int s[M][N];
    int p[M];
    int i2str[10];
    int answer = 0;
    int check = 0;

    int i,j,l;
    for(i = 0; i < M; i++){
        cin >> k[i];
        for(j = 0; j < k[i]; j++){
            cin >> s[i][j];
        }
    }
    for(i = 0; i < M; i++){
        cin >> p[M];
    }
    //i=行、j=列
    for(i = 0; i < pow(2,N); i++){
        for(l = 0; l < 10; l++){
            i2str[l] = i % 2;
            i /= 2;
        }
        for(j = 0; j < k[i]; j++){
            check += i2str[s[i][j] - 1];
            if(check % 2 != p[i]){
               ok = false;
               break;
            }
        }
    answer += ok;
    }
    cout << answer;
    return 0;
}
