#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  memset(a, -1, sizeof(a));
  for (long long i = 0; i < m; i++) {
    long long a1[3];
    cin >> a1[0] >> a1[1] >> a1[2];
    bool b[4];
    memset(b, 0, sizeof(b));
    for (long long j = 0; j < 3; j++) {
      if (a[a1[j] - 1] != -1) b[a[a1[j] - 1]] = 1;
    }
    long long k = 1;
    for (long long j = 0; j < 3; j++) {
      if (a[a1[j] - 1] == -1) {
        while (k <= 3) {
          if (b[k] == 0) {
            a[a1[j] - 1] = k;
            b[k] = 1;
            break;
          } else {
            k++;
          }
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
