G[0]=(1,2); G[1]=(1,3); G[2]=(1,5);
G[3]=(2,3); G[4]=(3,4); G[5]=(4,1);
G[6]=(4,5);
head[1]=0; head[2]=3; head[3]=4; head[4]=5; head[5]=-1;
len[1]=3; len[1]=3; len[3]=1; len[4]=2; len[5]=0;
struct node{
int to,next,w;
}edge[maxe];
int head[maxn];//头结点数组
#include<bits/stdc++.h>
//#define LOCAL
#define sum(a) ( accumulate ((a).begin(), (a).end(), 0int))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a) ( max_element((a).begin(), (a).end()) - (a).begin())
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
#define print(x) cout<<(x)<<'\n'
#define print_v(x) for (int iii = 0; iii < (x).size() - 1; ++iii) {cout << (x)[iii] << ' ';}cout << (x)[(x).size() - 1]<< '\n'
using namespace std;
#define mp make_pair
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5 + 5;
struct {
int to, w, next;
} edge[MAXN * 2];
int head[MAXN];
int cnt;
int n;
int x, y, m, z;
void add(int u, int v, int w) {
edge[++cnt].to = v;
edge[cnt].w = w;
edge[cnt].next = head[u];
head[u] = cnt;
}
void printing() {
for (int v = 1; v <= n; v++) {
cout << v << ": ";
for (int i = head[v]; i != -1; i = edge[i].next) {
int v1 = edge[i].to, w1 = edge[i].w;
cout << "[" << v1 << " " << w1 << "]\t";
}
cout << endl;
}
}
vector<int> path;
void dfs(int x) {
vis[x] = 1;
path.push_back(x);
for (int i = head[x]; i != -1; i = edges[i].next) {
if (!vis[edges[i].to])dfs(edges[i].to);
}
}
void bfs(int x) {
queue<int> q;
q.push(x);
vis[x] = 1;
while (!q.empty()) {
int now = q.front();
q.pop();
path.push_back(now);
for (int i = head[now]; i != -1; i = edges[i].next) {
if (!vis[edges[i].to]) {
q.push(edges[i].to);
vis[edges[i].to]=1;
}
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef LOCAL
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
cin >> n >> m;
memset(head, -1, sizeof(head));
while (m--) {
cin >> x >> y >> z;
add(x, y, z);
add(y, x, z);
}
printing();
}