#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  ;
  int a[100001] = {0};
  int b[100001] = {0};
  while (m--) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    ;
    if (b[x] != 0) {
      if (b[x] == 1) {
        b[y] = 2;
        b[z] = 3;
      } else if (b[x] == 2) {
        b[y] = 1;
        b[z] = 3;
      } else {
        b[y] = 1;
        b[z] = 2;
      }
    } else if (b[y] != 0) {
      if (b[y] == 1) {
        b[x] = 2;
        b[z] = 3;
      } else if (b[y] == 2) {
        b[x] = 1;
        b[z] = 3;
      } else {
        b[x] = 1;
        b[z] = 2;
      }
    } else if (b[z] != 0) {
      if (b[z] == 1) {
        b[y] = 2;
        b[x] = 3;
      } else if (b[z] == 2) {
        b[y] = 1;
        b[x] = 3;
      } else {
        b[y] = 1;
        b[x] = 2;
      }
    } else {
      b[x] = 1;
      b[y] = 2;
      b[z] = 3;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      printf("%d", b[i]);
    } else {
      printf(" %d", b[i]);
    }
  }
  return 0;
}
