#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> bulb(m, vector<int>());
  vector<int> p(m);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    while (k--) {
      int s;
      cin >> s;
      s--;
      bulb[i].push_back(s);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    bool isValid = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (auto b : bulb[i]) {
        if (mask & (1 << b)) cnt++;
      }
      if (cnt % 2 != p[i]) {
        isValid = false;
        break;
      }
    }
    if (isValid) ans++;
  }
  cout << ans << endl;
}
