1 #include<bits/stdc++.h>
2 using namespace std;
3 struct edge{
4 int to;
5 int s;
6 edge(int _to,int _s){to=_to,s=_s;}
7 };
8 int n,m;
9 vector<edge>e[1009];
10
11
12 int main()
13 {
14 cin>>n>>m;
15 for(int i=1;i<=n;i++)
16 {
17 int a,b,c;
18 cin>>a>>b>>c;
19 e[a].push_back(edge(b,c));
20 e[b].push_back(edge(a,c));
21 }
22 for(int i=1;i<=m;i++)
23 {
24 /*
25 for(vector<edge>::iterator it=e[i].begin();it!=e[i].end();it++)
26 {
27 printf("%d->%d cost:%d\n",i,it->to,it->s);
28 }
29 */
30 for(int j=0;j<e[i].size();j++)
31 {
32 printf("%d->%d cost:%d\n",i,e[i][j].to,e[i][j].s);
33 }
34 }
35 return 0;
36 }