#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long max(long long x, long long y) {
  if (x > y)
    return x;
  else
    return y;
}
long long min(long long x, long long y) {
  if (x > y)
    return y;
  else
    return x;
}
long long po(long long x, long long y) {
  long long k = 1, i;
  for (long long i = 0; i < y; i++) k = k * x;
  return k;
}
long long sum(long long x) {
  long long s = 0;
  while (x) {
    s = s + x % 10;
    x = x / 10;
  }
  return s;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i, j, n, l, m, k, p;
  cin >> n >> m;
  vector<long long> a(n + 1, 0);
  for (long long i = 0; i < m; i++) {
    cin >> j >> k >> l;
    if ((a[j] == 0) && (a[k] == 0) && (a[l] == 0)) {
      a[j] = 1;
      a[k] = 2;
      a[l] = 3;
    } else if (a[j] == 0) {
      if ((a[k] == 2) && (a[l] == 0)) {
        a[l] = 3;
        a[j] = 1;
      } else if ((a[k] == 3) && (a[l] == 0)) {
        a[l] = 2;
        a[j] = 1;
      } else if ((a[k] == 1) && (a[l] == 0)) {
        a[j] = 2;
        a[l] = 3;
      } else if ((a[l] == 2) && (a[k] == 0)) {
        a[k] = 3;
        a[j] = 1;
      } else if ((a[l] == 3) && (a[k] == 0)) {
        a[j] = 1;
        a[k] = 2;
      } else if ((a[l] == 1) && (a[k] == 0)) {
        a[k] = 3;
        a[j] = 2;
      } else {
        for (long long i = 1; i < 4; i++) {
          if ((a[l] != i) && (a[k] != i)) {
            a[j] = i;
            break;
          }
        }
      }
    } else if (a[j] == 1) {
      if ((a[k] == 0) && (a[l] == 0)) {
        a[k] = 2;
        a[l] = 3;
      } else if ((a[k] == 2) && (a[l] == 0))
        a[l] = 3;
      else if ((a[k] == 3) && (a[l] == 0))
        a[l] = 2;
      else if ((a[l] == 2) && (a[k] == 0))
        a[k] = 3;
      else if ((a[l] == 3) && (a[k] == 0))
        a[k] = 2;
    } else if (a[j] == 2) {
      if ((a[k] == 0) && (a[l] == 0)) {
        a[k] = 1;
        a[l] = 3;
      } else if ((a[k] == 1) && (a[l] == 0))
        a[l] = 3;
      else if ((a[k] == 3) && (a[l] == 0))
        a[l] = 1;
      else if ((a[l] == 1) && (a[k] == 0))
        a[k] = 3;
      else if ((a[l] == 3) && (a[k] == 0))
        a[k] = 1;
    } else {
      if ((a[k] == 0) && (a[l] == 0)) {
        a[k] = 1;
        a[l] = 2;
      } else if ((a[k] == 1) && (a[l] == 0))
        a[l] = 2;
      else if ((a[k] == 2) && (a[l] == 0))
        a[l] = 1;
      else if ((a[l] == 1) && (a[k] == 0))
        a[k] = 2;
      else if ((a[l] == 1) && (a[k] == 0))
        a[k] = 2;
    }
  }
  for (long long i = 1; i < n + 1; i++) cout << a[i] << " ";
  return 0;
}
