#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 200;
int partial_solution[2][2][N][N][N];
int final_solution[N][N][2];
int open_chains[N][N][N], closed_chains[N][N][N];
int n, m;
int answer[N];
vector<int> visions[N * N];
int start_node[N * N], end_node[N * N];
int edge_id[N][N];
void modular_addition(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
pair<int, int> find_vision_chain(vector<int> &temp_chain, int initial_node,
                                 bool flag) {
  int cindex = 0;
  int a, b;
  a = initial_node;
  while (cindex + 1 <= temp_chain.size()) {
    int b = temp_chain[cindex];
    int current_edge = edge_id[a][b];
    if (current_edge < 1 || current_edge > 2 * n || flag != (current_edge > m))
      return pair<int, int>(200000, -1);
    for (int j = 0; j < visions[current_edge].size(); j++) {
      temp_chain.push_back(visions[current_edge][j]);
    }
    a = b;
    cindex++;
  }
  return pair<int, int>(temp_chain.size(), a);
}
void calculate_chains(bool flag) {
  memset(open_chains, 0, sizeof(open_chains));
  memset(closed_chains, 0, sizeof(closed_chains));
  for (int i = 1; i <= 2 * m; i++)
    if ((i <= m) ^ flag) {
      for (int j = 0; j < visions[i].size(); j++)
        if (visions[i][j] == start_node[i]) {
          vector<int> temp_forward_chain, temp_backward_chain;
          for (int k = j - 1; k >= 0; k--)
            temp_forward_chain.push_back(visions[i][k]);
          pair<int, int> forward_chain =
              find_vision_chain(temp_forward_chain, start_node[i], flag ^ 1);
          if (forward_chain.first > 2 * n) continue;
          if (j + 1 == visions[i].size())
            open_chains[forward_chain.second][end_node[i]]
                       [forward_chain.first + 1]++;
          else {
            if (visions[i][j + 1] != end_node[i]) continue;
            for (int k = j + 2; k < visions[i].size(); k++)
              temp_backward_chain.push_back(visions[i][k]);
            pair<int, int> backward_chain =
                find_vision_chain(temp_backward_chain, end_node[i], flag);
            if (forward_chain.first + 1 + backward_chain.first <= 2 * n)
              closed_chains[forward_chain.second][backward_chain.second]
                           [backward_chain.first + 1 + forward_chain.first]++;
          }
        }
    }
}
void calculate_tables() {
  calculate_chains(false);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k < 2 * n; k++) {
        partial_solution[1][1][i][j][k] = closed_chains[i][j][k];
        partial_solution[1][0][i][j][k] = open_chains[i][j][k];
      }
  calculate_chains(true);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= 2 * n; k++)
        partial_solution[0][1][j][i][k] = open_chains[i][j][k];
}
void calculate_final_solution() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= 2 * n; k++)
        for (int v = 0; v <= 1; v++)
          modular_addition(final_solution[k][j][v],
                           partial_solution[1][v][i][j][k]);
  int ans;
  for (int k = 1; k <= 2 * n; k++) {
    ans = 0;
    for (int i = 1; i <= n; i++) {
      modular_addition(ans, final_solution[k][i][1]);
      for (int mid = 0; mid <= 1; mid++)
        if (final_solution[k][i][mid]) {
          for (int end = 0; end <= 1; end++)
            for (int z = 1; z <= n; z++)
              for (int len = 1; len <= 2 * n - k; len++)
                modular_addition(final_solution[k + len][z][end],
                                 final_solution[k][i][mid] * 1ll *
                                     partial_solution[mid ^ 1][end][i][z][len] %
                                     MOD);
        }
    }
    printf("%d\n", ans);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b, k;
    scanf("%d%d%d", &a, &b, &k);
    edge_id[a][b] = i;
    start_node[i] = a;
    end_node[i] = b;
    for (int j = 1; j <= k; j++) {
      int tv;
      scanf("%d", &tv);
      visions[i].push_back(tv);
    }
    edge_id[b][a] = i + m;
    start_node[i + m] = b;
    end_node[i + m] = a;
    for (int j = k - 1; j >= 0; j--) visions[i + m].push_back(visions[i][j]);
    if (k == 0) partial_solution[0][0][a][b][1]++;
  }
  calculate_tables();
  calculate_final_solution();
  return 0;
}
