#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[100000 + 5];
int b[100000 + 5];
int c[100000 + 5];
int ans[100000 + 5];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < m; i++) {
      scanf("%d%d%d", &a[i], &b[i], &c[i]);
      int x = a[i], y = b[i], z = c[i];
      if (ans[x] == 0 && ans[y] == 0 && ans[z] == 0)
        ans[x] = 1, ans[y] = 2, ans[z] = 3;
      else if (ans[x] == 0 && ans[y] == 0) {
        if (ans[z] == 1)
          ans[x] = 3, ans[y] = 2, ans[z] = 1;
        else if (ans[z] == 2)
          ans[x] = 1, ans[y] = 3, ans[z] = 2;
        else
          ans[x] = 1, ans[y] = 2, ans[z] = 3;
      } else if (ans[x] == 0 && ans[z] == 0) {
        if (ans[y] == 1)
          ans[x] = 2, ans[y] = 1, ans[z] = 3;
        else if (ans[y] == 2)
          ans[x] = 1, ans[y] = 2, ans[z] = 3;
        else if (ans[y] == 3)
          ans[x] = 1, ans[y] = 3, ans[z] = 2;
      } else if (ans[y] == 0 && ans[z] == 0) {
        if (ans[x] == 1)
          ans[x] = 1, ans[y] = 2, ans[z] = 3;
        else if (ans[x] == 2)
          ans[x] = 2, ans[y] = 1, ans[z] = 3;
        else if (ans[x] == 3)
          ans[x] = 3, ans[y] = 2, ans[z] = 1;
      } else if (ans[x] == 0) {
        if (ans[y] == 2 && ans[z] == 3)
          ans[x] = 1;
        else if (ans[y] == 1 && ans[z] == 3)
          ans[x] = 2;
        else if (ans[y] == 2 && ans[z] == 1)
          ans[x] = 3;
        else if (ans[y] == 3 && ans[z] == 2)
          ans[x] = 1;
      } else if (ans[y] == 0) {
        if (ans[x] == 1 && ans[z] == 3)
          ans[y] = 2;
        else if (ans[x] == 1 && ans[z] == 2)
          ans[y] = 3;
        else if (ans[x] == 2 && ans[z] == 3)
          ans[y] = 1;
        else if (ans[x] == 3 && ans[z] == 1)
          ans[y] = 2;
      } else if (ans[z] == 0) {
        if (ans[x] == 1 && ans[y] == 2)
          ans[z] = 3;
        else if (ans[x] == 1 && ans[y] == 3)
          ans[z] = 2;
        else if (ans[x] == 3 && ans[y] == 2)
          ans[z] = 1;
        else if (ans[x] == 2 && ans[y] == 1)
          ans[z] = 3;
      }
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
}
