#include <bits/stdc++.h>
using namespace std;
template <class A>
void pr(A a) {
  cout << (a) << endl;
}
template <class A, class B>
void pr(A a, B b) {
  cout << a << " ";
  pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
  cout << a << " ";
  pr(b, c);
}
template <class A, class B, class C, class D>
void pr(A a, B b, C c, D d) {
  cout << a << " ";
  pr(b, c, d);
}
template <class T>
inline bool chmin(T& a, T b) {
  return a > b ? a = b, true : false;
}
template <class T>
inline bool chmax(T& a, T b) {
  return a < b ? a = b, true : false;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<int> s(m);
  for (int i = 0; i < int(m); ++i) {
    cin >> k[i];
    for (int j = 0; j < int(k[i]); ++j) {
      int si;
      cin >> si;
      si--;
      s[j] |= 1 << si;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < int(m); ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < int(1 << n); ++i) {
    bool flag = true;
    for (int j = 0; j < int(m); ++j) {
      if (__builtin_popcount(i & s[j]) % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag == true) ans++;
  }
  pr(ans);
}
