#include <bits/stdc++.h>
using namespace std;
const int maxk = 10;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > light;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    vector<int> ss;
    light.push_back(ss);
    for (int l = 0; l < k; l++) {
      int s;
      cin >> s;
      s--;
      light[i].push_back(s);
    }
  }
  vector<int> p;
  for (int i = 0; i < m; i++) {
    int pp;
    cin >> pp;
    p.push_back(pp);
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int on = 0;
      for (int k = 0; k < n; k++) {
        if (bit & (1 << k)) {
          if (binary_search(light[i].begin(), light[i].end(), k)) {
            on++;
          }
        }
      }
      if (on % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
