#include <iostream>
#include <vector>

bool check(
    int M, std::vector<char>& sw,
     std::vector<std::vector<int>>& s,
      std::vector<int>& p)
{
    int on = 0;
    for (int i = 0; i < M; i++) {
        int c = 0;
        auto & ks = s[i];
        for (auto & sno : ks) {
            c += sw[sno];
        }
        if (c % 2 == p[i]) on++;
    }

    return (on == M);
}

std::vector<char> cre(int N, int n)
{
    std::vector<char> res(N, 0);
    for (int i = N-1; i >= 0; i--) {
        res[i] = n % 2;
        n /= 2;
    }
}

int main()
{
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<int>> s(N);

    // for lights
    for (int i = 0; i < M; i++) {
        int k;
        std::cin >> k;
        s[i].reserve(k);
        for (int j = 0; j < k; j++) {
            int sj;
            std::cin >> sj;
            s[i].push_back(sj);
        }
    }

    // for switch
    std::vector<int> p(M);
    for (int i = 0; i < M; i++) {
        std::cin >> p[i];
    }

    int x = 1;
    for (int i = 0; i < N; i++) {
        x *= 2;
    }

    int ans = 0;
    for (int i = 0; i < x; i++) {
        std::vector<char> chk = cre(N, i);
        if (check(M, chk, s, p)) {
            ans+++
        }
    }
    
    std::cout << ans << std::endl;

    return 0;
}