#include <bits/stdc++.h>
using namespace std;
const int maxn = 15;
int n, m, p[maxn], ans = 0;
set<int> a[maxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int k;
    cin >> k;
    while (k--) {
      int x;
      cin >> x;
      a[x].insert(i);
    }
  }
  for (int i = 1; i <= m; ++i) cin >> p[i];
  int lim = pow(2, n);
  int swit[maxn], time[maxn];
  for (int i = 0; i < lim; i++) {
    int tmp = i, cnt = m, flag = 1;
    for (int j = 0; j < maxn; j++) swit[j] = time[j] = 0;
    while (tmp) swit[cnt--] = tmp % 2, tmp >>= 1;
    for (int j = 1; j <= m; j++)
      if (swit[j])
        for (auto p : a[j]) time[p]++;
    for (int j = 1; j <= m; j++)
      if (time[j] % 2 != p[j]) {
        flag = 0;
        break;
      }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
