#include<iostream>
#include<queue>
#include<algorithm>
#include<numeric>
#include<string>
#include<map>
#include<bitset>

using namespace std;
using int_greater_PQ = priority_queue<int,vector<int>,greater<int>>;

//return 2^n
constexpr int CCnt(int n)
{
    int cnt=1;
    for (int i = 0; i < n; i++)
    {
        cnt *= 2;
    }
    return cnt;
}

int main() 
{
    int N,M;
    cin>>N>>M;

    vector<bitset<10>> Sk(M);
    for (int i = 0; i < M; i++)
    {
        int k;
        cin>>k;
        for (int j = 0; j < k; j++)
        {
            int s;
            cin>>s;
            Sk[i] |= s;
        }
    }

    vector<int>P;
    for (int i = 0; i < M; i++)
    {
        int p;
        cin>>p;
        P.push_back(p);
    }
    
    const int all = CCnt(N);
    int ans=0;

    for (int i = 1; i < all+1; i++)
    {
        bitset<10> I(i);
        for (int j = 0; j < M; j++)
        {
            auto sk = Sk[j] & I;
            bool ok = sk.count()%2==P[j];
            if(!ok)
            {
                break;
            }

            if(j==M-1)
            {
                ++ans;
            }
        }
    }

    cout<<ans<<endl;
    return 0;    

}
