#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100015;
int color[MAXN];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    int x, y, z;
    memset(color, 0, sizeof(color));
    for (int i = 1; i <= m; i++) {
      scanf("%d%d%d", &x, &y, &z);
      if (color[x] != 0) {
        color[y] = color[x] + 1;
        color[z] = color[x] + 2;
        if (color[y] > 3) color[y] %= 3;
        if (color[z] > 3) color[z] %= 3;
      } else if (color[y] != 0) {
        color[x] = color[y] + 2;
        color[z] = color[y] + 1;
        if (color[x] > 3) color[x] %= 3;
        if (color[z] > 3) color[z] %= 3;
      } else if (color[z] != 0) {
        color[x] = color[z] + 1;
        color[y] = color[z] + 2;
        if (color[y] > 3) color[y] %= 3;
        if (color[x] > 3) color[x] %= 3;
      } else {
        color[x] = 1;
        color[y] = 2;
        color[z] = 3;
      }
    }
    for (int i = 1; i <= n; i++)
      if (i == 1)
        printf("%d", color[i]);
      else
        printf(" %d", color[i]);
    printf("\n");
  }
}
