#include <bits/stdc++.h>
using namespace std;
const int N = 105, M = 5005;
int length_limit;
int eid[N][N];
int e[M][3];
vector<int> ev[M];
int n, m;
class State {
 public:
  int eL, vR;
  deque<int> Q;
  State() {
    eL = -1;
    vR = -1;
    Q = deque<int>();
  }
  State(const State &state) {
    eL = state.eL;
    vR = state.vR;
    Q = state.Q;
  }
  bool handle(int id, int &nowlen);
  bool operator<(const State &s) const {
    if (eL != s.eL) return eL < s.eL;
    if (vR != s.vR) return vR < s.vR;
    return Q < s.Q;
  }
  void print() const;
};
map<State, int> dp[N];
int secondfree[N][N][M];
bool State::handle(int id, int &nowlen) {
  if (e[id][2] == 0) return false;
  vector<int> V;
  if (vR >= 0) V.push_back(vR);
  Q.push_back(id);
  for (__typeof((ev[id]).begin()) it = (ev[id]).begin(); it != (ev[id]).end();
       it++)
    V.push_back(*it);
  for (int i = 1; i < ((int)(V).size()) &&
                  nowlen + ((int)(V).size()) - (vR >= 0) <= length_limit;
       i++) {
    int u = V[i - 1], v = V[i];
    if (eid[u][v] == -1) return false;
    int fx = eid[u][v];
    if (e[fx][2] == 0) continue;
    if (Q.empty()) {
      Q.push_back(fx);
      for (__typeof((ev[fx]).begin()) it = (ev[fx]).begin();
           it != (ev[fx]).end(); it++)
        V.push_back(*it);
      continue;
    }
    if (eL >= 0 && secondfree[ev[eL].back()][ev[Q.front()][0]][fx]) {
      nowlen += e[fx][2];
      continue;
    }
    if (Q.front() == fx) {
      eL = fx;
      Q.pop_front();
      continue;
    }
    return false;
  }
  nowlen += ((int)(V).size()) - (vR >= 0);
  if (nowlen + ((int)(Q).size()) > length_limit) return false;
  vR = V.back();
  return true;
}
void State::print() const {
  printf("eL=%d, vR=%d : ", eL, vR);
  for (__typeof((Q).begin()) it = (Q).begin(); it != (Q).end(); it++)
    printf("%d,", *it);
  puts("");
}
void input() {
  memset(eid, -1, sizeof(eid));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &e[i][0], &e[i][1]);
    --e[i][0], --e[i][1];
    int x = e[i][0], y = e[i][1];
    eid[x][y] = i;
    scanf("%d", &e[i][2]);
    for (int j = 0; j < e[i][2]; j++) {
      int w;
      scanf("%d", &w);
      --w;
      ev[i].push_back(w);
    }
  }
}
void build() {
  for (int l = 0; l < n; l++)
    for (int r = 0; r < n; r++)
      for (int id = 0; id < m; id++) {
        vector<int> S;
        S.push_back(l);
        for (__typeof((ev[id]).begin()) it = (ev[id]).begin();
             it != (ev[id]).end(); it++)
          S.push_back(*it);
        S.push_back(r);
        int &ok = secondfree[l][r][id];
        ok = 1;
        for (int i = 1; i < ((int)(S).size()); i++)
          if (eid[S[i - 1]][S[i]] == -1 || e[eid[S[i - 1]][S[i]]][2] > 0) {
            ok = 0;
            break;
          }
      }
}
int answer[N];
const int MOD = 1e9 + 7;
void add(int &x, int v) { x = (x + v) % MOD; }
void solve() {
  length_limit = 2 * n + 1;
  for (int i = 1; i <= length_limit; i++) dp[i].clear();
  State init;
  dp[0][init] = 1;
  for (int i = 0; i <= length_limit; i++) {
    for (__typeof((dp[i]).begin()) it = (dp[i]).begin(); it != (dp[i]).end();
         it++) {
      const State &st = it->first;
      if (st.Q.empty()) add(answer[i], it->second);
      for (int id = 0; id < m; id++) {
        State new_state = st;
        int newlen = i;
        bool ret = new_state.handle(id, newlen);
        if (ret) add(dp[newlen][new_state], it->second);
      }
    }
  }
  for (int i = 2; i <= length_limit; i++) printf("%d\n", answer[i]);
}
int main(void) {
  input();
  build();
  solve();
  return 0;
}
