//에지리스트 구현
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
typedef tuple<int, int, int> edge;
vector<edge> mlist;
int main()
{
int i, j, a, b, c;
int start, end, time;
int V, E;
cin >> V >> E; //정점, 에지
for(i=0;i<E;i++)
{
cin >> start >> end >> time;
mlist.push_back(make_tuple(start, end, time));
}
for(i=0;i<mlist.size();i++)
{
//tie(a, b, c) = mlist[i];
edge temp = mlist[i];
a = get<0>(temp);
b = get<1>(temp);
c = get<2>(temp);
cout << '(' << a << ' '<< b << ' ' << c <<')' ;
}
return 0;
}