#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long maxn = 1000000000;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vs = vector<string>;
using pll = pair<long long, long long>;
int main() {
  int n, m, nans = 0;
  cin >> n >> m;
  vvi s(m, vector<int>(n));
  vi k(m), p(m);
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> k.at(i);
    for (int(j) = 0; (j) < (k.at(i)); (j)++) cin >> s.at(i).at(j);
  }
  for (int(i) = 0; (i) < (m); (i)++) cin >> p.at(i);
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bool ans = true;
    bitset<10> s(tmp);
    for (int(i) = 0; (i) < (m); (i)++) {
      int ns = 0;
      for (int(j) = 0; (j) < (k.at(i)); (j)++) {
        if (s.test(k.at(i) - 1)) ns += 1;
      }
      if ((ns % 2) != p.at(i)) {
        ans = false;
        break;
      }
    }
    if (ans) nans++;
  }
  cout << nans / 2 << endl;
}
