#include <bits/stdc++.h>
using namespace std;
int main() {
  int dancers, dances;
  scanf("%d %d", &dancers, &dances);
  int color[100001][4], fix[100001];
  memset(fix, -1, sizeof fix);
  int x[4];
  memset(color, 0, sizeof color);
  for (int i = 1; i <= dances; i++) {
    for (int j = 1; j <= 3; j++) {
      scanf("%d", &x[j]);
      if (fix[x[j]] != -1) {
        color[i][fix[x[j]]] = 1;
        continue;
      }
    }
    for (int j = 1; j <= 3; j++) {
      if (fix[x[j]] != -1) continue;
      for (int k = 1; k <= 3; k++)
        if (color[i][k] == 0) {
          fix[x[j]] = k;
          color[i][k] = 1;
          break;
        }
    }
  }
  for (int i = 1; i <= dancers; i++) {
    printf("%d", fix[i]);
    if (i == dancers)
      printf("\n");
    else
      printf(" ");
  }
}
