#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  int mask[11] = {};
  for (long long i = (1); i <= (m); i++) {
    int k;
    cin >> k;
    for (long long j = (1); j <= (k); j++) {
      int s;
      cin >> s;
      mask[i] += (1 << (j - 1));
    }
  }
  int p[11] = {};
  for (long long i = (1); i <= (m); i++) {
    cin >> p[i];
  }
  long long res = 0;
  long long validcnt = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    for (long long i = (1); i <= (m); i++) {
      int temp = mask[i] & bit;
      int oncnt = 0;
      while (temp > 0) {
        if (temp % 2 == 1) {
          oncnt++;
        }
        temp = temp >> 1;
      }
      if (oncnt % 2 == p[i]) {
        validcnt++;
      }
    }
    if (validcnt == m) {
      res++;
    }
    validcnt = 0;
  }
  cout << (res) << endl;
  return (0);
}
