#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > vv;
  for (int i = 0; i < m; i++) {
    vector<int> v;
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int t;
      cin >> t;
      v.push_back(t);
    }
    vv.push_back(v);
  }
  vector<int> b;
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    b.push_back(t);
  }
  int res = 0;
  for (int i = 0; i < pow(2, n); i++) {
    vector<int> sw(n, 0);
    int ii = i;
    int index = 0;
    while (ii > 0) {
      sw[index++] = ii % 2;
      ii /= 2;
    }
    int flag = 1;
    for (int j = 0; j < m; j++) {
      int c = 0;
      for (int k = 0; k < vv[j].size(); k++) {
        if (sw[vv[j][k]] == 1) {
          c = 1 - c;
        }
      }
      if (c != b[j]) flag = 0;
      if (flag == 0) break;
    }
    res += flag;
  }
  cout << res << endl;
}
