#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      s[i].push_back(y);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    bitset<10> l(tmp);
    bool check = true;
    for (int i = 0; i < m; i++) {
      int now = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (l.test(s[i][j])) now++;
      }
      if (!(now % 2 == p[i])) check = false;
    }
    if (check) ans++;
  }
  cout << ans << endl;
}
