#include <bits/stdc++.h>
using namespace std;
struct speed {
  speed() {
    cin.tie();
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(18);
  }
} speed;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  for (int i = 0; i < (int)m; i++) {
    int cnt;
    cin >> cnt;
    for (int j = 0; j < (int)cnt; j++) {
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  for (int i = 0; i < (int)m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (int)(1 << n); i++) {
    int flag = 1;
    for (int j = 0; j < (int)m; j++) {
      int cnt = 0;
      for (int k = 0; k < (int)s[j].size(); k++) {
        if (i & (1 << s[j][k])) {
          cnt++;
        }
      }
      if (cnt % 2 != p[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << "\n";
}
