#include <bits/stdc++.h>
using namespace std;
struct key3 {
  int a, b, c;
  key3(int aa, int bb, int cc) {
    a = aa;
    b = bb;
    c = cc;
  }
  key3() {}
};
int main() {
  int n, m;
  cin >> n >> m;
  key3 k[m];
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    k[i] = key3(a, b, c);
  }
  bool Done[n + 1];
  int Color[n + 1];
  memset(Done, false, sizeof(Done));
  for (int i = 0; i < m; i++) {
    if (Done[k[i].a]) {
      int c = Color[k[i].a];
      if (c == 1) {
        Color[k[i].b] = 2;
        Color[k[i].c] = 3;
      } else if (c == 2) {
        Color[k[i].b] = 3;
        Color[k[i].c] = 1;
      } else if (c == 3) {
        Color[k[i].b] = 1;
        Color[k[i].c] = 2;
      }
      Done[k[i].a] = true;
      Done[k[i].b] = true;
      Done[k[i].c] = true;
    } else if (Done[k[i].b]) {
      int c = Color[k[i].b];
      if (c == 1) {
        Color[k[i].a] = 2;
        Color[k[i].c] = 3;
      } else if (c == 2) {
        Color[k[i].a] = 3;
        Color[k[i].c] = 1;
      } else if (c == 3) {
        Color[k[i].a] = 1;
        Color[k[i].c] = 2;
      }
      Done[k[i].a] = true;
      Done[k[i].b] = true;
      Done[k[i].c] = true;
    } else if (Done[k[i].c]) {
      int c = Color[k[i].c];
      if (c == 1) {
        Color[k[i].b] = 2;
        Color[k[i].a] = 3;
      } else if (c == 2) {
        Color[k[i].b] = 3;
        Color[k[i].a] = 1;
      } else if (c == 3) {
        Color[k[i].b] = 1;
        Color[k[i].a] = 2;
      }
      Done[k[i].a] = true;
      Done[k[i].b] = true;
      Done[k[i].c] = true;
    } else {
      Color[k[i].a] = 1;
      Color[k[i].b] = 2;
      Color[k[i].c] = 3;
      Done[k[i].a] = true;
      Done[k[i].b] = true;
      Done[k[i].c] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << Color[i] << " ";
  }
  return 0;
}
