#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > a(m);
  for (int i = 0; i < m; i++) {
    int s;
    cin >> s;
    a[i].resize(s);
    for (int j = 0; j < s; j++) cin >> a[i][j];
  }
  vector<int> p(m);
  vector<int> s(n);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 1; i <= pow(2, n) - 1; i++) {
    int k = 0;
    for (int j = 0; j < m; j++) {
      int so = 0;
      for (auto u : a[j]) {
        so += (i & (1 << (u - 1))) ? 1 : 0;
      }
      if ((so % 2) != p[j]) {
        k = 1;
        break;
      }
    }
    if (!k) ans++;
  }
  cout << ans << endl;
  return 0;
}
