#include <bits/stdc++.h>
using namespace std;
int mArr[100001][4];
int arr[100001];
int m;
bool dressArrange(int a, int b, int c, int ct) {
  int setValues = 0;
  int col[] = {1, 2, 3};
  if (ct != 0) {
    arr[mArr[ct - 1][1]] = a;
    arr[mArr[ct - 1][2]] = b;
    arr[mArr[ct - 1][3]] = c;
  } else if (ct == m)
    return true;
  bool validPerm = true;
  bool result;
  do {
    if (arr[mArr[ct][1]] != 0 && col[0] != arr[mArr[ct][1]]) {
      continue;
    } else if (arr[mArr[ct][2]] != 0 && col[1] != arr[mArr[ct][2]]) {
      continue;
    } else if (arr[mArr[ct][3]] != 0 && col[2] != arr[mArr[ct][3]])
      continue;
    result = dressArrange(col[0], col[1], col[2], ct + 1);
    if (result)
      return true;
    else
      continue;
  } while (next_permutation(col, col + 3));
  return true;
}
int main() {
  int i, j, k;
  int n;
  int d1, d2, d3;
  int col[4];
  int count = 0;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 0; i < n; i++) arr[i] = 0;
  for (i = 0; i < m; i++) {
    scanf("%d", &mArr[i][1]);
    scanf("%d", &mArr[i][2]);
    scanf("%d", &mArr[i][3]);
  }
  bool result = dressArrange(0, 0, 0, 0);
  for (i = 1; i <= n; i++) printf("%d ", arr[i]);
  printf("\n");
  return 0;
}
