#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int color[n + 1];
  memset(color, 0, sizeof(color));
  int t;
  bool temp[4];
  for (int i = 0; i < m; ++i) {
    memset(temp, 0, sizeof(temp));
    int t[3];
    for (int j = 0; j < 3; ++j) {
      scanf("%d", &t[j]);
    }
    for (int j = 0; j < 3; ++j) {
      if (color[t[j]]) {
        temp[color[t[j]]] = 1;
      }
    }
    for (int j = 0; j < 3; ++j) {
      if (color[t[j]]) {
        continue;
      }
      int k;
      for (k = 1; k <= 3; ++k) {
        if (!temp[k]) {
          break;
        }
      }
      temp[k] = 1;
      color[t[j]] = k;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (color[i] == 0) {
      printf("1 ");
      continue;
    }
    printf("%d ", color[i]);
  }
  printf("\n");
  return 0;
}
