#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> ump;
  if (n >= 3 * m) {
    for (long long i = 0; i < m; i++) {
      long long a, b, c;
      cin >> a >> b >> c;
      ump[a] = 1;
      ump[b] = 2;
      ump[c] = 3;
    }
  } else {
    for (long long i = 0; i < m; i++) {
      long long a, b, c;
      cin >> a >> b >> c;
      if (ump.count(a) != 0) {
        long long d = ump[a];
        if (d == 1) {
          ump[b] = 2;
          ump[c] = 3;
        }
        if (d == 2) {
          ump[b] = 1;
          ump[c] = 3;
        }
        if (d == 3) {
          ump[b] = 1;
          ump[c] = 2;
        }
        continue;
      }
      if (ump.count(b) != 0) {
        long long d = ump[b];
        if (d == 1) {
          ump[a] = 2;
          ump[c] = 3;
        }
        if (d == 2) {
          ump[a] = 1;
          ump[c] = 3;
        }
        if (d == 3) {
          ump[a] = 1;
          ump[c] = 2;
        }
        continue;
      }
      if (ump.count(c) != 0) {
        long long d = ump[c];
        if (d == 1) {
          ump[b] = 2;
          ump[a] = 3;
        }
        if (d == 2) {
          ump[b] = 1;
          ump[a] = 3;
        }
        if (d == 3) {
          ump[b] = 1;
          ump[a] = 2;
        }
        continue;
      }
      ump[a] = 1;
      ump[b] = 2;
      ump[c] = 3;
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << ump[i] << " ";
  }
  return 0;
}
