#include <bits/stdc++.h>
using namespace std;
const int N = 105, M = 5005;
int length_limit;
int eid[N][N];
int e[M][3];
int ebreak[M];
int expand_length[M];
vector<int> ev[M];
vector<int> ee_notfree[M];
int n, m;
int free_shortest_path[N][N];
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;
  Q.push_back(id);
  int vEnd = vR;
  vector<int> E;
  if (vR >= 0) E.push_back(eid[vR][ev[id][0]]);
  for (__typeof((ee_notfree[id]).begin()) it = (ee_notfree[id]).begin();
       it != (ee_notfree[id]).end(); it++)
    E.push_back(*it);
  nowlen += e[id][2];
  vEnd = ev[id].back();
  for (int i = 0; i < ((int)(E).size()) && nowlen <= length_limit; i++) {
    if (E[i] == -1) return false;
    int fx = E[i];
    if (e[fx][2] == 0) continue;
    if (Q.empty()) {
      if (nowlen + expand_length[fx] > length_limit) return false;
      E.push_back(eid[vEnd][ev[fx][0]]);
      for (__typeof((ee_notfree[fx]).begin()) it = (ee_notfree[fx]).begin();
           it != (ee_notfree[fx]).end(); it++)
        E.push_back(*it);
      vEnd = ev[fx].back();
      eL = fx;
      nowlen += e[fx][2];
      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;
  }
  if (nowlen + ((int)(Q).size()) > length_limit) return false;
  int est = 0, esL = eL;
  for (int i = 0; i < ((int)(Q).size()); esL = Q[i++])
    if (esL >= 0)
      est += free_shortest_path[ev[esL].back()][ev[Q[i]].front()] + 1;
  if (nowlen + est > length_limit) return false;
  vR = vEnd;
  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);
    }
  }
}
int insidefree[M];
void build() {
  for (int id = 0; id < m; id++)
    for (int i = 1; i < ((int)(ev[id]).size()); i++) {
      int u = ev[id][i - 1], v = ev[id][i];
      if (eid[u][v] == -1) {
        ee_notfree[id].push_back(-1);
        ebreak[id] = 1;
      }
      if (eid[u][v] >= 0 && e[eid[u][v]][2] > 0)
        ee_notfree[id].push_back(eid[u][v]);
    }
  for (int id = 0; id < m; id++) {
    insidefree[id] = 1;
    for (int i = 1; i < e[id][2]; i++)
      if (eid[ev[id][i - 1]][ev[id][i]] == -1 ||
          eid[ev[id][i - 1]][ev[id][i]] > 0) {
        insidefree[id] = 0;
        break;
      }
  }
  for (int l = 0; l < n; l++)
    for (int r = 0; r < n; r++)
      for (int id = 0; id < m; id++) {
        if (eid[l][r] != -1 && e[eid[l][r]][2] > 0) {
          secondfree[l][r][id] = 0;
          continue;
        }
        if (e[id][2] == 0) {
          secondfree[l][r][id] =
              (eid[l][r] != -1 && e[eid[l][r]][2] == 0) ? 1 : 0;
          continue;
        }
        if (insidefree[id] == 0) {
          secondfree[l][r][id] = 0;
          continue;
        }
        if (eid[l][ev[id][0]] == -1 || eid[ev[id].back()][r] == -1) {
          secondfree[l][r][id] = 0;
          continue;
        }
        if (e[eid[l][ev[id][0]]][2] == 0 && e[eid[ev[id].back()][r]][2] == 0)
          secondfree[l][r][id] = 1;
        else
          secondfree[l][r][id] = 0;
      }
  const int INF = 10000;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      free_shortest_path[i][j] =
          (i == j ? 0 : (e[eid[i][j]][2] == 0 ? 1 : INF));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int id = 0; id < m; id++)
        if (secondfree[i][j][id])
          free_shortest_path[i][j] = min(free_shortest_path[i][j], e[id][2]);
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (free_shortest_path[i][j] >
            free_shortest_path[i][k] + free_shortest_path[k][j])
          free_shortest_path[i][j] =
              free_shortest_path[i][k] + free_shortest_path[k][j];
  for (int id = 0; id < m; id++) expand_length[id] = e[id][2];
  for (int T = 0; T < n; T++)
    for (int id = 0; id < m; id++) {
      if (ebreak[id]) {
        expand_length[id] = INF;
        continue;
      }
      expand_length[id] = e[id][2];
      for (int j = 1; j < e[id][2]; j++) {
        int me = eid[ev[id][j - 1]][ev[id][j]];
        if (me != id)
          expand_length[id] +=
              expand_length[e[eid[ev[id][j - 1]][ev[id][j]]][2]];
      }
    }
}
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;
  vector<int> e_not_free;
  for (int id = 0; id < m; id++)
    if (e[id][2] != 0) e_not_free.push_back(id);
  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);
      if (m >= 1000 && i > 0 && st.Q.empty()) continue;
      for (__typeof((e_not_free).begin()) jt = (e_not_free).begin();
           jt != (e_not_free).end(); jt++) {
        int id = *jt;
        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;
}
