#include <bits/stdc++.h>
using namespace std;
int fx[] = {0, 0, 1, -1};
int fy[] = {-1, 1, 0, 0};
vector<int> ve[100005];
int col[15], st[10];
int main() {
  int n, m, p, q, r, i, j;
  scanf("%d %d", &n, &m);
  for (j = 0; j < m; j++) {
    st[1] = st[2] = st[3] = 0;
    cin >> p >> q >> r;
    st[col[p]] = 1;
    st[col[q]] = 1;
    st[col[r]] = 1;
    if (col[p] == col[q] && col[q] == col[r] && col[r] == 0) {
      col[p] = 1;
      col[q] = 2;
      col[r] = 3;
    } else {
      if (col[p] == 0) {
        for (i = 1; i <= 3; i++) {
          if (st[i] == 0) {
            st[i] = 1;
            col[p] = i;
            break;
          }
        }
      }
      if (col[q] == 0) {
        for (i = 1; i <= 3; i++) {
          if (st[i] == 0) {
            st[i] = 1;
            col[q] = i;
            break;
          }
        }
      }
      if (col[r] == 0) {
        for (i = 1; i <= 3; i++) {
          if (st[i] == 0) {
            st[i] = 1;
            col[r] = i;
            break;
          }
        }
      }
    }
  }
  int f = 0;
  for (i = 1; i <= n; i++) {
    if (f == 1) printf(" ");
    f = 1;
    printf("%d", col[i]);
  }
  puts("");
  return 0;
}
