# include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(1e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int n, m, ans, light[20];
int a[20][20], p[12], kk[20];

bool ok (){
    for (int i = 1; i <= m; ++i){
        int cur = 0;
        for (int j = 1; j <= kk[i]; ++j){
            if (light[a[i][j]]) cur++;
        }
        cur %= 2;
        if (cur != p[i]) return 0;
    }
    return 1;
}

int main (){
    scanf ("%d %d", &n, &m);
    for (int i = 1; i <= m; ++i){
        scanf ("%d", kk + i);
        for (int j = 1; j <= kk[i]; ++j){
            scanf ("%d", &a[i][j]);
        }
    }
    for (int i = 1; i <= m; ++i) scanf ("%d", p + i);
    ans += ok();
    for (int d = 1; d <= n; ++d){
        memset (light, 0, sizeof(light));
        if (d == 1){
            for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    if (ok()) ans++;
                    light[i] = 0;
                }
            }
        }
        else if (d == 2){
            for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            if (ok()) ans++;
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 3){
            for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    if (ok()) ans++;
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 4){
              for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            if (ok()) ans++;
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 5){
             for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            for (int t = l + 1; t <= n; ++t){
                                                if (light[t] == 0){
                                                    light[t] = 1;
                                                    ans += ok();
                                                    light[t] = 0;
                                                }
                                            }
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 6){
                for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            for (int t = l + 1; t <= n; ++t){
                                                if (light[t] == 0){
                                                    light[t] = 1;
                                                    for (int q = t + 1; q <= n; ++q){
                                                        if (light[q] == 0){
                                                            light[q] = 1;
                                                            ans += ok();
                                                            light[q] = 0;
                                                        }
                                                    }
                                                    light[t] = 0;
                                                }
                                            }
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 7){
            for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            for (int t = l + 1; t <= n; ++t){
                                                if (light[t] == 0){
                                                    light[t] = 1;
                                                    for (int q = t + 1; q <= n; ++q){
                                                        if (light[q] == 0){
                                                            light[q] = 1;
                                                            for (int w = q + 1; w <= n; ++w){
                                                                if (light[w] == 0){
                                                                    light[w] = 1;
                                                                    ans += ok();
                                                                    light[w] = 0;
                                                                }
                                                            }
                                                            light[q] = 0;
                                                        }
                                                    }
                                                    light[t] = 0;
                                                }
                                            }
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 8){
               for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            for (int t = l + 1; t <= n; ++t){
                                                if (light[t] == 0){
                                                    light[t] = 1;
                                                    for (int q = t + 1; q <= n; ++q){
                                                        if (light[q] == 0){
                                                            light[q] = 1;
                                                            for (int w = q + 1; w <= n; ++w){
                                                                if (light[w] == 0){
                                                                    light[w] = 1;
                                                                    for (int e = w + 1; e <= n; ++e){
                                                                        if (light[e] == 0){
                                                                            light[e] = 1;
                                                                            ans += ok();
                                                                            light[e] = 0;
                                                                        }
                                                                    }
                                                                    light[w] = 0;
                                                                }
                                                            }
                                                            light[q] = 0;
                                                        }
                                                    }
                                                    light[t] = 0;
                                                }
                                            }
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 9){
                           for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            for (int t = l + 1; t <= n; ++t){
                                                if (light[t] == 0){
                                                    light[t] = 1;
                                                    for (int q = t + 1; q <= n; ++q){
                                                        if (light[q] == 0){
                                                            light[q] = 1;
                                                            for (int w = q + 1; w <= n; ++w){
                                                                if (light[w] == 0){
                                                                    light[w] = 1;
                                                                    for (int e = w + 1; e <= n; ++e){
                                                                        if (light[e] == 0){
                                                                            light[e] = 1;
                                                                            for (int r = e + 1; r <= n; ++r){
                                                                                if (light[r] == 0){
                                                                                    light[r] = 1;
                                                                                    ans += ok();
                                                                                    light[r] = 0;
                                                                                }
                                                                            }
                                                                            light[e] = 0;
                                                                        }
                                                                    }
                                                                    light[w] = 0;
                                                                }
                                                            }
                                                            light[q] = 0;
                                                        }
                                                    }
                                                    light[t] = 0;
                                                }
                                            }
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
        else if (d == 10){
                    for (int i = 1; i <= n; ++i){
                if (light[i] == 0){
                    light[i] = 1;
                    for (int j = i + 1; j <= n; ++j){
                        if (light[j] == 0){
                            light[j] = 1;
                            for (int k = j + 1; k <= n; ++k){
                                if (light[k] == 0){
                                    light[k] = 1;
                                    for (int l = k + 1; l <= n; ++l){
                                        if (light[l] == 0){
                                            light[l] = 1;
                                            for (int t = l + 1; t <= n; ++t){
                                                if (light[t] == 0){
                                                    light[t] = 1;
                                                    for (int q = t + 1; q <= n; ++q){
                                                        if (light[q] == 0){
                                                            light[q] = 1;
                                                            for (int w = q + 1; w <= n; ++w){
                                                                if (light[w] == 0){
                                                                    light[w] = 1;
                                                                    for (int e = w + 1; e <= n; ++e){
                                                                        if (light[e] == 0){
                                                                            light[e] = 1;
                                                                            for (int r = e + 1; r <= n; ++r){
                                                                                if (light[r] == 0){
                                                                                    light[r] = 1;
                                                                                    for (int u = r + 1; u <= n; ++u){
                                                                                        if (light[u] == 0){
                                                                                            light[u] = 1;
                                                                                            ans += ok();
                                                                                            light[u] = 0;
                                                                                        }
                                                                                    }
                                                                                    light[r] = 0;
                                                                                }
                                                                            }
                                                                            light[e] = 0;
                                                                        }
                                                                    }
                                                                    light[w] = 0;
                                                                }
                                                            }
                                                            light[q] = 0;
                                                        }
                                                    }
                                                    light[t] = 0;
                                                }
                                            }
                                            light[l] = 0;
                                        }
                                    }
                                    light[k] = 0;
                                }
                            }
                            light[j] = 0;
                        }
                    }
                    light[i] = 0;
                }
            }
        }
    }
    return !printf ("%d\n", ans);
}


Measured memory_bytes: 256