#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <class Type>
inline constexpr Type Square(Type x) {
  return x * x;
}
template <class Type>
inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) {
  return (i <= x) && (x <= a);
}
template <class Integer>
bool chmax(Integer& a, const Integer& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Integer>
bool chmin(Integer& a, const Integer& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Integer>
bool IsOdd(Integer& n) {
  return n & 1;
}
template <class Integer>
bool IsEven(Integer& n) {
  return !(n & 1);
}
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}
void Print() { cout << endl; }
template <class Head, class... Tail>
void Print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  Print(forward<Tail>(tail)...);
}
template <class Type>
void Print(vector<Type>& vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
template <class Type>
void Print(vector<vector<Type>>& df) {
  for (auto& vec : df) {
    Print(vec);
  }
}
void Debug() { cerr << endl; }
template <class Head, class... Tail>
void Debug(Head&& head, Tail&&... tail) {
  cerr << head;
  if (sizeof...(tail) != 0) cerr << " ";
  Debug(forward<Tail>(tail)...);
}
template <class Type>
void Debug(vector<Type>& vec) {
  for (auto& a : vec) {
    cerr << a;
    if (&a != &vec.back()) cerr << " ";
  }
  cerr << endl;
}
template <class Type>
void Debug(vector<vector<Type>>& df) {
  for (auto& vec : df) {
    Debug(vec);
  }
}
int main() {
  int N, M;
  _cin(N, M);
  vector<int> k(M);
  vector<vector<int>> s(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> k[i];
    for (int m = 0, m_len = (k[i]); m < m_len; ++m) {
      int _s;
      _cin(_s);
      _s--;
      s[i].push_back(_s);
    }
  }
  vector<int> p(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 0, bit_len = (1 << N); bit < bit_len; ++bit) {
    set<int> on_set;
    for (int i = 0, i_len = (N); i < i_len; ++i) {
      if (bit & (1 << i)) {
        on_set.insert(i);
      }
    }
    int cnt = 0;
    bool ok = true;
    for (int i = 0, i_len = (M); i < i_len; ++i) {
      for (int m = 0, m_len = (k[i]); m < m_len; ++m) {
        if (on_set.find(s[i][m]) != on_set.end()) {
          cnt++;
        }
      }
      ok &= (cnt % 2 == p[i]);
    }
    if (ok) {
      ans++;
    }
  }
  Print(ans);
  return 0;
}
