#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> k;
vector<vector<int>> s;
vector<int> p;
bool judgeOnOff(long long int i, int j) {
  vector<int> s_for_j = s.at(j);
  int num = 0;
  for (int k = 0; k < s_for_j.size(); k++) {
    if (i & (1 << k)) {
      num++;
    }
  }
  if (num % 2 == p.at(j)) {
    return true;
  }
  return false;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    k.push_back(x);
    s.push_back({});
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      s.at(i).push_back(y - 1);
    }
  }
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    p.push_back(x);
  }
  int ans = 0;
  for (long long int i = 0; i < (1 << N); i++) {
    vector<bool> light_bulb_onoff;
    bool flag = true;
    for (int j = 0; j < M; j++) {
      if (!judgeOnOff(i, j)) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}
