#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<vector<int>> light(m + 1, vector<int>(n + 1));
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      light.at(i).at(s) = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    light.at(i).at(0) = p;
  }
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<10> s(tmp);
    bool flag = true;
    for (int i = 1; i <= m; i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        if (light.at(i).at(j) == 1 && s.test(j - 1)) {
          sum++;
        }
      }
      if (!(sum % 2 == light.at(i).at(0))) {
        flag = false;
      }
    }
    if (flag) ans++;
  }
  cout << ans;
}
