#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T& RD(T& x) {
  char c;
  for (c = getchar(); c < '0'; c = getchar())
    ;
  x = c - '0';
  for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x;
}
const int inf = 0x3f3f3f3f;
const int maxn = 100005;
int a[maxn];
int c[6][3] = {1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(a, 0, sizeof(a));
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    for (int j = 0; j < 6; j++) {
      if (a[x] == 0)
        ;
      else if (a[x] == c[j][0])
        ;
      else
        continue;
      if (a[y] == 0)
        ;
      else if (a[y] == c[j][1])
        ;
      else
        continue;
      if (a[z] == 0)
        ;
      else if (a[z] == c[j][2])
        ;
      else
        continue;
      a[x] = c[j][0];
      a[y] = c[j][1];
      a[z] = c[j][2];
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) a[i] = 1;
    printf("%d \n", a[i]);
  }
  return 0;
}
