#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9 = 1000000000;
const ll mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s2;
      cin >> s2;
      s2--;
      s[i].push_back(s2);
    }
  }
  for (int i = 0; i < m; ++i) cin >> p[i];
  int cnt = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    int temp = 0;
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < s[i].size(); ++j) {
        if (bit & (1 << s[i][j])) temp++;
      }
      if (temp % 2 != p[i]) flag = false;
    }
    if (flag) cnt++;
  }
  cout << cnt << endl;
}
