#include <bits/stdc++.h>
using namespace std;
vector<int> s[22], p(22);
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k, a;
    cin >> k;
    for (int j = 0; j < k; j++) cin >> a, s[j].push_back(a);
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int c = 0;
  for (int i = 0; i < 1 << n; i++) {
    for (int j = 0; j < m; j++) {
      int b = p[j];
      for (int a : s[j]) b ^= i >> a - 1;
      if (b & 1) goto pn;
    }
    c++;
  pn:;
  }
  cout << c << endl;
  return 0;
}
