#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<vector<int>> con;
  vector<int> ps(m);
  for (int i = 0; i < m; ++i) {
    int num;
    cin >> num;
    vector<int> tmp(num);
    for (int i = 0; i < num; ++i) cin >> tmp[i];
    con.emplace_back(tmp);
  }
  for (int i = 0; i < m; ++i) cin >> ps[i];
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool can = false;
    for (int i = 0; i < m; ++i) {
      can = false;
      int sum = 0;
      for (auto itr = con[i].begin(); itr != con[i].end(); ++itr) {
        if (bit & (1 << *itr)) sum++;
      }
      if (sum % 2 == ps[i])
        can = true;
      else
        can = false;
      if (!can) break;
    }
    if (can) ans++;
  }
  cout << (ans) << "\n";
}
