#include <bits/stdc++.h>
using namespace std;
int vis[100100], a[100100][4], b[100100];
int main() {
  int i, j, n, m;
  while (scanf("%d %d", &n, &m) != EOF) {
    memset(vis, 0, sizeof(vis));
    memset(b, 0, sizeof(b));
    for (i = 1; i <= m; i++) {
      int cnt = 0;
      for (j = 1; j <= 3; j++) {
        cin >> a[i][j];
        if (vis[a[i][j]] == 0) {
          vis[a[i][j]] = 1;
        } else
          cnt = j;
      }
      if (cnt == 0) {
        b[a[i][1]] = 1;
        b[a[i][2]] = 2;
        b[a[i][3]] = 3;
      }
      if (cnt == 1) {
        b[a[i][2]] = b[a[i][1]] % 3 + 1;
        b[a[i][3]] = (b[a[i][2]]) % 3 + 1;
      }
      if (cnt == 2) {
        b[a[i][3]] = (b[a[i][2]] % 3 + 1);
        b[a[i][1]] = (b[a[i][3]] % 3 + 1);
      }
      if (cnt == 3) {
        b[a[i][1]] = (b[a[i][3]] % 3 + 1);
        b[a[i][2]] = (b[a[i][1]] % 3 + 1);
      }
    }
    for (i = 1; i <= n; i++) cout << b[i] << " ";
    cout << endl;
  }
}
