#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int n, m, f[4][100005], c[100005], vis[100005];
vector<int> adj[100005];
void BFS(int x) {
  queue<int> q;
  q.push(x);
  vis[x] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (auto i : adj[u]) {
      f[c[i]][u] = 1;
      if (!vis[i]) {
        vis[i] = 1;
        q.push(i);
      }
    }
    for (int i = 1; i <= 3; i++) {
      if (!f[i][u]) {
        c[u] = i;
        break;
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    adj[a].push_back(b);
    adj[b].push_back(a);
    adj[c].push_back(b);
    adj[b].push_back(c);
    adj[a].push_back(c);
    adj[c].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) BFS(i);
    printf("%d ", c[i]);
  }
  return 0;
}
