#pragma comment(linker, "/STACK:1024000000,1024000000") #include"stdio.h" #include"string.h" #include"iostream" #include"map" #include"string" #include"queue" #include"stdlib.h" #include"math.h" #define M 1100009 #define eps 1e-10 #define inf 1000000000 #define mod 1000000000 #define INF 1000000000 using namespace std; struct node { int v,w; node(int vv,int ww) { v=vv; w=ww; } }; int n,k; vector<node>edge[101]; int dfs(int u,int f) { printf("%d ",u); for(int i=0;i<edge[u].size();i++) { int v=edge[u][i].v; if(f!=v) dfs(v,u); } } int main() { int n,m,i; while(scanf("%d%d",&n,&m)!=-1) { for(i=1;i<=n;i++) { std::vector<node>().swap(edge[i]); } while(m--) { int a,b,c; scanf("%d%d%d",&a,&b,&c); edge[a].push_back(node(b,c)); edge[b].push_back(node(a,c)); } dfs(1,1); printf(" "); } }