#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> allPossibleSubset(int arr[], int n) {
  int count = pow(2, n);
  vector<vector<int>> powerSet;
  powerSet.resize(count);
  for (int i = 0; i < count; i++) {
    vector<int> temp;
    for (int j = 0; j < n; j++) {
      if ((i & (1 << j)) > 0) temp.push_back(arr[j]);
    }
    powerSet.push_back(temp);
  }
  return powerSet;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<set<int>> switches;
  int nums[m];
  switches.resize(m);
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    for (int j = 0; j < x; ++j) {
      int temp;
      cin >> temp;
      switches.at(i).insert(temp);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> nums[i];
  }
  int arr[n];
  for (int i = 0; i < n; ++i) {
    arr[i] = i + 1;
  }
  vector<vector<int>> temp = allPossibleSubset(arr, n);
  long long total = 0;
  for (auto i : temp) {
    if (i.size() == 0) continue;
    int lights = 0;
    for (int k = 0; k < switches.size(); k++) {
      int num = 0;
      for (auto j : i) {
        if (switches.at(k).find(j) != switches.at(k).end()) {
          num++;
        }
      }
      if (num % 2 == nums[k]) lights++;
    }
    if (lights == m) total++;
  }
  cout << total << '\n';
  cout.flush();
  return 0;
}
