#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> bulbs;
vector<int> crits;
int count_intersections(vector<int> &a, vector<int> &b) {
  vector<int> c(10);
  auto it = set_intersection(a.begin(), a.end(), b.begin(), b.end(), c.begin());
  c.resize(it - c.begin());
  return c.size();
}
bool check(vector<int> &closed_switches) {
  for (int i = 0; i < bulbs.size(); i++) {
    if (count_intersections(bulbs[i], closed_switches) % 2 != crits[i]) {
      return false;
    }
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int j;
    cin >> j;
    vector<int> switches;
    while (j--) {
      int k;
      cin >> k;
      switches.push_back(k);
    }
    bulbs.push_back(switches);
  }
  for (int i = 0; i < m; i++) {
    int j;
    cin >> j;
    crits.push_back(j);
  }
  int result = 0;
  for (int state = 0; state <= (1 << (n + 1) - 1); state++) {
    vector<int> closed_switches;
    for (int j = 0; j < n; j++) {
      if (state & (1 << j)) {
        closed_switches.push_back(j + 1);
      }
    }
    if (check(closed_switches)) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}
