#include <bits/stdc++.h>
using namespace std;
int v[100010];
int n, m;
vector<tuple<int, int, int> > vt;
int main() {
  cin >> n >> m;
  for (int i = 0, u, vv, w; i < m; i++) {
    cin >> u >> vv >> w;
    vt.emplace_back(u, vv, w);
  }
  for (int i = 0; i < m; i++) {
    int vec[4];
    tie(vec[0], vec[1], vec[2]) = vt[i];
    bool col[4];
    col[0] = col[1] = col[2] = col[3] = 0;
    for (int i = 0; i < 3; i++) col[v[vec[i]]] = 1;
    for (int j = 0; j < 3; j++) {
      if (v[vec[j]] == 0) {
        for (int k = 1; k <= 3; k++) {
          if (!col[k]) {
            col[k] = true, v[vec[j]] = k;
            break;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << v[i] << " ";
  return 0;
}
