#include <bits/stdc++.h>
using namespace std;
void solve();
void getInput();
int N, M;
vector<vector<int>> lights;
vector<int> P;
signed main() {
  getInput();
  solve();
  return 0;
}
void getInput() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int k;
    cin >> k;
    vector<int> LtoS = vector<int>(k, 0);
    for (int j = 0; j < k; ++j) {
      int in;
      cin >> in;
      LtoS[j] = in - 1;
    }
    lights.push_back(LtoS);
  }
  P = vector<int>(M, 0);
  for (int i = 0; i < M; ++i) {
    cin >> P[i];
  }
}
void solve() {
  int ans = 0;
  for (int i = 0; i < (1 << N); ++i) {
    vector<bool> res(M, false);
    for (int j = 0; j < M; ++j) {
      auto& light = lights[j];
      for (auto s : light) {
        if (i & 1 << s) {
          res[j] = !res[j];
        }
      }
    }
    bool a = true;
    for (auto l : res) {
      a *= l;
    }
    if (a) ans++;
  }
  cout << ans << endl;
}
