#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> v;
bitset<11> p;
void read() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    vector<int> temp;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      temp.push_back(s);
    }
    v.push_back(temp);
  }
  for (int i = 0; i < m; ++i) {
    bool x;
    cin >> x;
    if (x)
      p[i] = 1;
    else
      p[i] = 0;
  }
}
void solve() {
  int sol = 0, l = (1 << n);
  for (int i = 1; i < l; ++i) {
    bitset<11> activated;
    for (int j = 0; j < n; ++j)
      if ((1 << j) & i) {
        activated[j] = true;
      }
    vector<int> bulb(m);
    for (int j = 0; j < n; ++j)
      if (activated[j])
        for (int k = 0; k < m; ++k)
          for (auto x : v[k])
            if (x == j + 1) ++bulb[k];
    bool good = 1;
    for (int j = 0; j < m && good; ++j)
      if (bulb[j] % 2 != p[j]) good = 0;
    if (good) ++sol;
  }
  cout << sol;
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(nullptr);
  read();
  solve();
  return 0;
}
