#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v[m];
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int f;
      cin >> f;
      v[i].push_back(f);
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  queue<string> q;
  q.push("1");
  int f = pow(2, n) - 1;
  int count = 0;
  while (f--) {
    int flag = 0;
    vector<int> arr(n, 0);
    string s1 = q.front();
    q.pop();
    int sn = s1.length();
    for (int i = 0; i < sn; i++) {
      arr[n - sn + i] = s1[i] - '0';
    }
    for (int i = 0; i < m; i++) {
      int c = 0;
      for (int j = 0; j < v[i].size(); j++) {
        if (arr[v[i][j] - 1] == 1) c++;
      }
      if (c % 2 != p[i]) flag = 1;
    }
    if (flag == 0) count++;
    string s2 = s1;
    q.push(s1.append("0"));
    q.push(s2.append("1"));
  }
  cout << count;
}
