#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
template <class T>
void print(T& x) {
  cout << x << '\n';
}
const int MOD = (int)1e9 + 7;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMint() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  if (a > b) {
    swap(a, b);
  }
  return gcd(a, b % a);
}
long long lcm(long long a, long long b) {
  long long g;
  g = gcd(a, b);
  return a * b / g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second < b.second;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N = in();
  int M = in();
  vector<vector<int>> s(M);
  int _k;
  for (int i = 0; i < (M); ++i) {
    cin >> _k;
    int temp;
    for (int j = 0; j < (_k); ++j) {
      cin >> temp;
      s[i].push_back(temp);
    }
    sort((s[i]).begin(), (s[i]).end());
  }
  vector<int> p(M);
  for (int i = 0; i < (M); ++i) {
    cin >> p[i];
  }
  long long ans = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    cerr << "bit"
         << ": " << bit << '\n';
    vector<int> k(M);
    for (int j = 0; j < (M); ++j) {
      k[j] = 0;
    }
    bool flg;
    flg = true;
    for (int j = 0; j < (M); ++j) {
      int l;
      l = 0;
      for (int i = 0; i < N; i++) {
        if (i + 1 == s[j][l]) {
          if (bit & (1 << (N - 1 - i))) {
            k[j] = (k[j] + 1) % 2;
          }
          l++;
        }
      }
      if (k[j] != p[j]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      cerr << "bit"
           << ": " << bit << '\n';
      ans = ans + 1;
    }
  }
  print(ans);
  return 0;
}
