#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      s[i].push_back(a);
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) cin >> p[i];
  int S = 0;
  for (int b = 0; b < (1 << n); b++) {
    int l = 0;
    for (int i = 0; i < m; i++) {
      int t = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (b & (1 << s[i][j])) t++;
      }
      if (t % 2 == p[i]) l++;
    }
    if (l == m) S++;
  }
  cout << S << endl;
}
