#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> K(M);
  vector<vector<int>> S(M);
  for (int i = 0; i < M; i++) {
    cin >> K.at(i);
    for (int j = 0; j < K.at(i); j++) {
      int s;
      cin >> s;
      S.at(i).push_back(s);
    }
  }
  int total = 1;
  for (int i = 0; i < M; i++) {
    int count = 0;
    for (int tmp = 0; tmp < (1 << 10); tmp++) {
      bitset<10> s(tmp);
      for (int j = 0; j < K.at(i); j++) {
        if (s.test(j)) count++;
      }
    }
    total *= count;
  }
  cout << total << endl;
}
