#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int x;
      cin >> x;
      x--;
      s[i].push_back(x);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  const int bsm = 1 << n;
  int ret = 0;
  for (int bs = 0; bs < bsm; bs++) {
    bool flg = false;
    for (int i = 0; i < m; i++) {
      int tmp = 0;
      for (int j = 0; j < k[i]; j++) {
        tmp ^= (bs >> s[i][j]) & 1;
      }
      if (tmp != p[i]) {
        flg = true;
        break;
      }
    }
    if (!flg) ret++;
  }
  cout << ret << endl;
  return 0;
}
