#include <bits/stdc++.h>
using namespace std;
vector<int> v[15];
int n, m;
int sh[15];
int check[15];
int bigcont;
bool checkf() {
  for (int i = 1; i <= m; i++) {
    int cont = 0;
    for (int j = 0; j < v[i].size(); j++) {
      if (check[v[i][j]]) cont++;
    }
    if (cont % 2 != sh[i]) return 0;
  }
  return 1;
}
void insfor(int m, int ind) {
  for (int i = ind; i <= n; i++) {
    check[i] = true;
    if (m > 1) insfor(m - 1, i + 1);
    bigcont += checkf();
    check[i] = false;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int z;
      cin >> z;
      v[i].push_back(z);
    }
  }
  for (int i = 1; i <= m; i++) cin >> sh[i];
  checkf();
  insfor(n, 1);
  cout << bigcont << endl;
  return 0;
}
