#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(n);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      s[i].push_back(--tmp);
    }
  }
  vector<int> p;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  int okCount = 0;
  for (int state = 0; state < pow(2, n); state++) {
    bool ngFlag = true;
    for (int denki = 0; denki < n; denki++) {
      int count = 0;
      for (int sw = 0; sw < s[denki].size(); sw++) {
        if (state & (1 << (s[denki][sw] - 1))) {
          count++;
        }
      }
      if (p[denki] != count % 2) {
        ngFlag = false;
        break;
      }
    }
    if (ngFlag) {
      okCount++;
    }
  }
  cout << okCount << endl;
}
