#include <vector>
#include <iostream>
using namespace std;
struct edge{
int from;
int to;
int cap;
} ;
int n,m;
vector< edge> list;
vector< vector< edge* > > adj;
int a,b,c;
edge t;
int main( ) {
cin >> n>> m;
int g= 0 ;
adj.resize ( n+ 3 ) ;
for ( int i= 0 ; i< m; i++ ) {
cin >> a>> b>> c;
t.from = a;
t.to = b;
t.cap = c;
list.push_back ( t) ;
g++ ;
adj[ a] .push_back ( & list[ g- 1 ] ) ;
adj[ b] .push_back ( & list[ g- 1 ] ) ;
}
for ( int i= 1 ; i<= n; i++ ) {
cout << "adjacent nodes of the node " << i<< " are :" << endl;
for ( int j= 0 ; j< adj[ i] .size ( ) ; j++ ) {
if ( adj[ i] [ j] - > from== i) {
cout << adj[ i] [ j] - > to<< " " ;
} else {
cout << adj[ i] [ j] - > from<< " " ;
}
}
cout << endl<< endl;
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IGVkZ2V7CglpbnQgZnJvbTsKCWludCB0bzsKCWludCBjYXA7Cn07CgppbnQgbixtOwp2ZWN0b3I8ZWRnZT4gbGlzdDsKdmVjdG9yPHZlY3RvcjxlZGdlKj4gPiBhZGo7CmludCBhLGIsYzsKZWRnZSB0OwppbnQgbWFpbigpewoJY2luPj5uPj5tOwoJaW50IGc9MDsKCWFkai5yZXNpemUobiszKTsKCWZvcihpbnQgaT0wO2k8bTtpKyspewoJCWNpbj4+YT4+Yj4+YzsKCQkKCQl0LmZyb209YTsKCQl0LnRvPWI7CgkJdC5jYXA9YzsKCQlsaXN0LnB1c2hfYmFjayh0KTsKCQlnKys7CgkJYWRqW2FdLnB1c2hfYmFjaygmbGlzdFtnLTFdKTsKCQlhZGpbYl0ucHVzaF9iYWNrKCZsaXN0W2ctMV0pOwoJfQoJZm9yKGludCBpPTE7aTw9bjtpKyspewoJCWNvdXQ8PCJhZGphY2VudCBub2RlcyBvZiB0aGUgbm9kZSAiPDxpPDwiIGFyZSA6Ijw8ZW5kbDsKCQlmb3IoaW50IGo9MDtqPGFkaltpXS5zaXplKCk7aisrKXsKCQkJaWYoYWRqW2ldW2pdLT5mcm9tPT1pKXsKCQkJCWNvdXQ8PGFkaltpXVtqXS0+dG88PCIgIjsKCQkJfSBlbHNlIHsKCQkJCWNvdXQ8PGFkaltpXVtqXS0+ZnJvbTw8IiAiOwoJCQl9CgkJfQoJCWNvdXQ8PGVuZGw8PGVuZGw7Cgl9Cn0=