#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long int MOD = 1e9 + 7;
const long long int INF = 1000000000;
const long long int MAX_N = 2e5 + 2;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> adj[m + 1], p(n + 1);
  for (int i = 1; i < m + 1; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      adj[i].push_back(s);
    }
  }
  for (int i = 1; i < n + 1; ++i) cin >> p[i];
  int ans = 0, cnt;
  for (int i = 0; i <= (1 << n); ++i) {
    int num = i, idx = n - 1;
    vector<int> set(n, 0);
    while (num && idx >= 0) {
      set[idx] = num & 1;
      num >>= 1, idx--;
    }
    bool flag = true;
    for (int i = 1; i < m + 1; ++i) {
      cnt = 0;
      for (int j = 0; j < (int)adj[i].size(); ++j) {
        cnt += (set[adj[i][j] - 1]);
      }
      if (cnt % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
