#include <bits/stdc++.h>
using namespace std;
int INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int count = 0;
  vector<int> bin(n);
  for (int b = 0; b < pow(2, n); b++) {
    int t = b;
    for (int i = n - 1; i >= 0; i--) {
      int in = pow(2, i);
      bin[i] = t / in;
      t = t % in;
    }
    bool flag = 1;
    int tmp = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < k[i]; j++) {
        tmp += bin[s[i][j] - 1];
      }
      if (tmp % 2 != p[i]) flag = 0;
    }
    if (flag) count++;
  }
  cout << count << endl;
  return 0;
}
