#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
constexpr long long mod = 1e9 + 7;
constexpr long long INF = mod * mod;
constexpr int MAX = 100010;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> G[n];
  for (int((i)) = (int)(0); ((i)) < (int)((m)); ++((i))) {
    int K;
    scanf("%d", &K);
    for (int((_)) = (int)(0); ((_)) < (int)((K)); ++((_))) {
      int s;
      scanf("%d", &s);
      --s;
      G[s].push_back(i);
    }
  }
  int ans = 0;
  for (int((S)) = (int)(0); ((S)) < (int)((1 << n)); ++((S))) {
    vector<int> bulb(m, 0);
    for (int((i)) = (int)(0); ((i)) < (int)((n)); ++((i)))
      if (S >> i & 1) {
        for (int j : G[i]) bulb[j] ^= 1;
      }
    int cnt = 0;
    if (accumulate(bulb.begin(), bulb.end(), 0) == m) ++ans;
  }
  printf("%d\n", ans);
}
