#include <bits/stdc++.h>
using namespace std;
int color[100005];
int main() {
  int n, m, i, j, a[3];
  bool changed;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    for (j = 0; j < 3; j++) scanf("%d", &a[j]);
    changed = false;
    for (j = 0; j < 3; j++) {
      if (color[a[j]]) {
        color[a[(j + 1) % 3]] = color[a[j]] % 3 + 1;
        color[a[(j + 2) % 3]] = color[a[(j + 1) % 3]] % 3 + 1;
        changed = true;
        break;
      }
    }
    if (!changed) {
      color[a[0]] = 1;
      color[a[1]] = 2;
      color[a[2]] = 3;
    }
  }
  for (i = 1; i < n + 1; i++) printf("%d ", color[i]);
  printf("\n");
  return 0;
}
