#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, w, j;
int i;
bool Fr[300010];
set<pair<int, int> > S;
set<pair<int, int> >::iterator it;
vector<pair<int, int> > V[300010];
int main() {
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> a >> b >> w;
    V[a].push_back(make_pair(i, w));
    V[b].push_back(make_pair(-i, w));
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < V[i].size(); j++) {
      if (V[i][j].first >= 0) S.insert(V[i][j]);
    }
    it = S.begin();
    while ((*it).second == i && it != S.end()) it++;
    if (it == S.end())
      cout << "0 ";
    else
      cout << (*it).second << " ";
    for (j = 0; j < V[i].size(); j++) {
      if (V[i][j].first < 0) {
        it = S.find(make_pair(-V[i][j].first, V[i][j].second));
        if (it != S.end()) S.erase(it);
      }
    }
  }
  return 0;
}
