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