#include <bits/stdc++.h>
using namespace std;
long long int cnt = 0;
vector<long long int> v[10];
long long int p[10];
long long int pwr(long long int a, long long int b) {
  if (b == 1) return a;
  long long int half = pwr(a, b / 2);
  if (b % 2 == 1)
    return half * half * a;
  else {
    return half * half;
  }
}
bool check(long long int* a, long long int n) {
  long long int flag = 0;
  for (long long int i = 0; i < 10; i++) {
    long long int s = v[i].size();
    long long int c = 0;
    for (long long int j = 0; j < s; j++) {
      if (a[v[i][j] - 1] == 1) c++;
    }
    if (c % 2 != p[i]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) return true;
  return false;
}
void poss(long long int* a, long long int n, long long int k) {
  if (k == n - 1) {
    a[n - 1] = 0;
    if (check(a, n)) {
      cnt++;
    }
    a[n - 1] = 1;
    if (check(a, n)) {
      cnt++;
    }
    return;
  }
  for (long long int i = k; i < n - 1; i++) {
    a[i] = 0;
    poss(a, n, i + 1);
    a[i] = 1;
    poss(a, n, i + 1);
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int a[n];
  long long int z;
  for (long long int i = 0; i < m; i++) {
    cin >> z;
    for (long long int j = 0; j < z; j++) {
      long long int x;
      cin >> x;
      v[i].push_back(x);
    }
  }
  for (long long int i = 0; i < m; i++) {
    cin >> p[i];
  }
  poss(a, n, 0);
  cout << cnt;
}
