#include<stdio.h>
#include<string.h>
#define inf 100000000
#define N 110
#define min(a,b) a>b?b:a;
int pre[N][N],dis[N][N],ma[N][N],path[N],num,minf;
int n,m;
void FLOYD() {
int i,j,k,s,p;
minf=inf;
for(k=1;k<=n;k++) {
for(i=1;i<k;i++)
for(j=i+1;j<k;j++) {
s=dis[i][j]+ma[i][k]+ma[k][j];
if(s<minf) {
num=0;
minf=s;
p=j;
while(p!=i) {
path[num++]=p;
p=pre[i][p];
}
path[num++]=i;
path[num++]=k;
}
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++) {
s=dis[i][k]+dis[k][j];
if(dis[i][j]>s) {
dis[i][j]=s;
pre[i][j]=pre[k][j];
}
}
}
}
int main() {
int i,j,v,u,w;
while(scanf("%d%d",&n,&m)!=EOF) {
for(i=1;i<=n;i++)
for(j=1;j<=n;j++) {
dis[i][j]=inf;
ma[i][j]=inf;
pre[i][j]=i;
}
num=0;
while(m--) {
scanf("%d%d%d",&u,&v,&w);
w=min(dis[u][v],w);
dis[u][v]=dis[v][u]=ma[u][v]=ma[v][u]=w;
}
FLOYD();
if(minf==inf) {
printf("No solution.
");
continue;
}
printf("%d",path[0]);
for(i=1;i<num;i++)
printf(" %d",path[i]);
printf("
");
}
return 0;
}