#include <bits/stdc++.h>
using namespace std;
int g[500020], cnt[4];
int main() {
  int i, j, k, T, n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (i = 1; i <= n; i++) g[i] = 0;
    for (i = 0; i < m; i++) {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      memset(cnt, 0, sizeof(cnt));
      cnt[g[a]]++;
      cnt[g[b]]++;
      cnt[g[c]]++;
      for (j = 1; j <= 3; j++)
        if (!cnt[j]) {
          if (!g[a]) {
            g[a] = j;
            continue;
          }
          if (!g[b]) {
            g[b] = j;
            continue;
          }
          if (!g[c]) {
            g[c] = j;
            continue;
          }
        }
    }
    for (i = 1; i <= n; i++) printf("%d ", g[i]);
    puts("");
  }
}
