#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
const int MAX_N = 50005;
const int MOD = 666013;
vector< pair<int, int> > restr[MAX_N];
int element[MAX_N];

class comparer {
public: inline bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return a.first > b.first;
    }
};

int main() {
    //ifstream cin("f.in");
    //ofstream cout("f.out");
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; ++ i) {
        int x, y, z;
        cin >> x >> y >> z;
        restr[x].push_back(make_pair(y, z));
    }
    for(int i = 1; i <= n; ++ i) {
        if(static_cast<int>(restr[i].size()) > 1) {
            sort(restr[i].begin(), restr[i].end(), comparer());
            for(int j = 1; j < static_cast<int>(restr[i].size()); ++ j) {
                if(restr[i][j].first == restr[i][j - 1].first) {
                    continue;
                } else {
                    restr[restr[i][j].first + 1].push_back(make_pair(restr[i][j - 1].first, restr[i][j - 1].second ^ restr[i][j].second));
                }
            }
        }
    }
    element[n + 1] = 0;
    for(int i = n; i >= 1; -- i) {
        if(restr[i].empty()) {
            element[i] = element[i + 1];
        } else {
            int k = restr[i][0].second ^ (element[i + 1] ^ element[restr[i][0].first + 1]);
            element[i] = element[i + 1] ^ k;
        }
    }
    for(int i = 1; i <= n; ++ i) {
        cout << (element[i] ^ element[i + 1]) << (i == n ? '\n' : ' ');
    }
    return 0;
}