#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<map<int, int>> s(m);
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int val;
      cin >> val;
      s[i][val] = 1;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (pow(2, n)); ++i) {
    map<int, int> mp;
    for (int j = 0; j < (n); ++j) {
      if (i & (1 << j)) {
        for (int k = 0; k < (m); ++k) {
          if (!mp[k]) mp[k] = 0;
          if (s[k][j + 1]) {
            mp[k]++;
          }
        }
      }
    }
    int light_num = 0;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
      if (itr->second % 2 == p[itr->first]) {
        light_num++;
      }
    }
    if (light_num == m) {
      ans++;
    }
  }
  cout << ans << endl;
}
