#include <bits/stdc++.h>
using namespace std;
const int M = 10;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> switches(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      switches[s].push_back(i);
    }
  }
  vector<int> remainders(m);
  for (int i = 0; i < m; i++) cin >> remainders[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bitset<M> bit(i);
    vector<int> each_bulb(m);
    for (int j = 0; j < m; j++) {
      if (bit[j]) {
        for (int k : switches[j]) each_bulb[k] = 1 - each_bulb[k];
      }
    }
    bool all = true;
    for (int i = 0; i < m; i++) {
      if (each_bulb[i] != remainders[i]) all = false;
    }
    if (all) ans++;
  }
  cout << ans << endl;
}
