#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
vector<int> edge[200010];
int out[200010];
int n, m, a, b, c;
int dfs(int i) {
  for (int j = (1); j <= (3); ++j) {
    for (int k = 0; k < ((int)edge[i].size()); ++k)
      if (out[edge[i][k]] == j) goto end;
    out[i] = j;
    for (int k = 0; k < ((int)edge[i].size()); ++k)
      if (out[edge[i][k]] <= 0) dfs(edge[i][k]);
  end:;
  }
  return 0;
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); ++i) edge[i].clear();
  for (int i = 0; i < (m); ++i) {
    scanf("%d%d%d", &a, &b, &c);
    edge[a].push_back(b);
    edge[a].push_back(c);
    edge[b].push_back(a);
    edge[b].push_back(c);
    edge[c].push_back(a);
    edge[c].push_back(b);
  }
  memset(out, 0, sizeof(out));
  for (int i = (1); i <= (n); ++i)
    if (!out[i]) dfs(i);
  for (int i = (1); i <= (n); ++i) printf("%d%c", out[i], i < n ? ' ' : '\n');
  return 0;
}
