#include <bits/stdc++.h>
using namespace std;
int ans[100005];
int edge[100005][3];
int av[5];
int main() {
  int i, j, n, m, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    for (j = 0; j < 3; j++) {
      scanf("%d", &edge[i][j]);
    }
  }
  memset(ans, 0, sizeof(ans));
  for (i = 0; i < n; i++) {
    memset(av, 0, sizeof(av));
    for (j = 0; j < 3; j++) {
      av[ans[edge[i][j]]] = 1;
    }
    for (k = 1; k <= 3; k++) {
      if (av[k] == 0) {
        for (j = 0; j < 3; j++) {
          if (ans[edge[i][j]] == 0) {
            ans[edge[i][j]] = k;
            break;
          }
        }
      }
    }
  }
  for (i = 1; i < n; i++) {
    printf("%d ", ans[i]);
  }
  printf("%d\n", ans[i]);
  return 0;
}
