#include#include const int maxn = 1e7 + 5 ; int u,v,d,used,n,m ; struct edge_ { int to ; int next ; int weight ; }Edge[maxn * 2]; int head[maxn] ; void push_edge (int from,int to,int d){ ++used ; Edge[used].to = to ; Edge[used].weight = d ; Edge[used].next = head[from] ; head[from] = used ; } int main (){ scanf("%d%d",&n,&m) ; for (int i = 1 ; i <= m ; ++i){ scanf("%d%d%d",&u,&v,&d) ; push_edge(u,v,d) ; push_edge(v,u,d) ; } for (int i = 1 ; i <= n ; ++i){ printf ("%dn",i) ; for (int j = head[i] ; j ; j = Edge[j].next) printf ("%d %dn",Edge[j].to,Edge[j].weight) ; } return 0 ; }



