#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() {
  int s, l;
  cin >> s >> l;
  vector<vector<int>> switches(s);
  for (int i = 0; i < (int)(s); ++i) {
    int x;
    cin >> x;
    vector<int> sandl(x);
    for (int i = 0; i < (int)(x); ++i) cin >> sandl[i];
    switches.push_back(sandl);
  }
  vector<int> lcond(l);
  for (int i = 0; i < (int)(l); ++i) cin >> lcond[i];
  long long ans = 0;
  for (int i = 0; i < (int)((1 << s)); ++i) {
    bitset<10> tmp(i);
    vector<bool> ifOn(l, false);
    for (int j = 0; j < (int)(s); ++j) {
      int x = 0;
      for (int k = 0; k < (int)(switches[j].size()); ++k) {
        if (tmp[switches[j][k] - 1] == 1) x++;
      }
      if (x % 2 == lcond[j]) ifOn[j] = true;
    }
    bool allon = true;
    for (int j = 0; j < (int)(l); ++j)
      if (!ifOn[j]) allon = false;
    if (allon) ans++;
  }
  cout << ans << endl;
}
