#include <bits/stdc++.h>
int main() {
  int n, m, a, b, c;
  scanf("%d %d", &n, &m);
  int arr[n][3];
  int ar[100000] = {0};
  int as[100000] = {0};
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &arr[i][0], &arr[i][1], &arr[i][2]);
    a = arr[i][0];
    b = arr[i][1];
    c = arr[i][2];
    if (ar[a] >= 1) {
      if (as[a] == 1) {
        as[b] = 2;
        as[c] = 3;
      } else if (as[a] == 2) {
        as[b] = 1;
        as[c] = 3;
      } else if (as[a] == 3) {
        as[b] = 1;
        as[c] = 2;
      }
    } else if (ar[b] >= 1) {
      if (as[b] == 1) {
        as[a] = 2;
        as[c] = 3;
      } else if (as[b] == 2) {
        as[a] = 1;
        as[c] = 3;
      } else if (as[b] == 3) {
        as[a] = 1;
        as[c] = 2;
      }
    } else if (ar[c] >= 1) {
      if (as[c] == 1) {
        as[a] = 2;
        as[b] = 3;
      } else if (as[c] == 2) {
        as[a] = 1;
        as[b] = 3;
      } else if (as[c] == 3) {
        as[a] = 1;
        as[b] = 2;
      }
    } else {
      as[a] = 1;
      as[b] = 2;
      as[c] = 3;
    }
    ar[a]++;
    ar[b]++;
    ar[c]++;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", as[i]);
  }
  return 0;
}
