#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, ans = 0;
  cin >> n >> m;
  vector<vector<int>> light(m);
  vector<int> num(m), prt(m);
  for (int i = 0; i < m; i++) {
    cin >> num[i];
    for (int j = 0; j < num[i]; j++) {
      int temp;
      cin >> temp;
      light[i].push_back(temp);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> prt[i];
  }
  for (int x = 0; x < (1 << n); x++) {
    bool jury = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < num[i]; j++) {
        if (x & (1 << (light[i][j] - 1))) {
          cnt++;
        }
      }
      if (cnt % 2 != prt[i]) {
        jury = false;
        break;
      }
    }
    if (jury) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
