#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> sw(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    vector<int> s(k);
    for (int j = 0; j < k; j++) cin >> s[j];
    sw[i] = s;
  }
  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++) {
    bool flag = true;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int k = 0; k < sw.size(); k++) {
        count += bitset<10>(i)[sw[j][k] - 1];
      }
      if (count % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
