#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = (1e9 + 7);
long long dp[100010];
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
long long lcg(long long x, long long y) { return x * y / gcd(x, y); }
map<long long, long long> factor(long long n) {
  map<long long, long long> ans;
  long long a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      ans[a]++;
      n /= a;
    } else
      a++;
  }
  ans[n]++;
  return ans;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  long long ss, ls;
  cin >> ss >> ls;
  vector<vector<long long>> ltos(ls);
  for (long long i = 0; i < (long long)(ls); ++i) {
    long long x;
    cin >> x;
    for (long long j = 0; j < (long long)(x); ++j) {
      long long y;
      cin >> y;
      ltos[i].push_back(y);
    }
  }
  vector<long long> cond(ls);
  for (long long i = 0; i < (long long)(ls); ++i) cin >> cond[i];
  long long ans = 0;
  for (long long i = 0; i < (long long)(1 << ss); ++i) {
    bitset<10> switches(i);
    vector<bool> isOn(ls, false);
    for (long long j = 0; j < (long long)(ls); ++j) {
      int x;
      for (long long k = 0; k < (long long)(ltos[j].size()); ++k)
        if (switches.test(ltos[j][k] - 1)) x++;
      if (x % 2 == cond[j]) isOn[j] = true;
    }
    bool allOn = true;
    for (long long j = 0; j < (long long)(ls); ++j)
      if (!isOn[j]) allOn = false;
    if (allOn) ans++;
  }
  cout << ans << endl;
}
