#include <bits/stdc++.h>
using namespace std;
long long __bigmod(long long __a, long long __b, long long __c) {
  if (__a == 0) return 0;
  if (__b == 0) return 1;
  if (__b % 2 == 0)
    return (((__bigmod(__a, __b / 2, __c) % __c) *
             (__bigmod(__a, __b / 2, __c) % __c)) %
            __c);
  else
    return (((__a % __c) * (__bigmod(__a, __b - 1, __c)) % __c) % __c) % __c;
}
long long __GCD(long long __a, long long __b) {
  if (__b == 0)
    return __a;
  else
    return __GCD(__b, __a % __b);
}
long long __LCM(long long __a, long long __b) {
  return (__a * __b) / __GCD(__a, __b);
}
long long __factorial(long long __number) {
  long long __ans = 1;
  for (long long __i = 1; __i <= __number; __i++) __ans = __ans * __i;
  return __ans;
}
long long __binary_search(long long __arr[], long long __low, long long __high,
                          long long __number) {
  while (__low <= __high) {
    long long __mid = (__low + __high) / 2;
    if (__number < __arr[__mid])
      __high = __mid - 1;
    else if (__number > __arr[__mid]) {
      __low = __mid + 1;
    } else
      return __mid;
  }
  return -1;
}
int main() {
  long long n, m;
  while (cin >> n >> m) {
    int arr[100000 + 5];
    for (int i = 1; i <= 100000; i++) arr[i] = 0;
    for (int i = 1; i <= m; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      set<int> emni;
      if (arr[a] == 0 && arr[b] == 0 && arr[c] == 0) {
        arr[a] = 1;
        arr[b] = 2;
        arr[c] = 3;
      } else {
        emni.insert(arr[a]);
        emni.insert(arr[b]);
        emni.insert(arr[c]);
        if (arr[a] == 0) {
          if (emni.count(1) == 0) {
            emni.insert(1);
            arr[a] = 1;
          } else if (emni.count(2) == 0) {
            emni.insert(2);
            arr[a] = 2;
          } else {
            emni.insert(3);
            arr[a] = 3;
          }
        }
        if (arr[b] == 0) {
          if (emni.count(1) == 0) {
            emni.insert(1);
            arr[b] = 1;
          } else if (emni.count(2) == 0) {
            emni.insert(2);
            arr[b] = 2;
          } else {
            emni.insert(3);
            arr[b] = 3;
          }
        }
        if (arr[c] == 0) {
          if (emni.count(1) == 0) {
            emni.insert(1);
            arr[c] = 1;
          } else if (emni.count(2) == 0) {
            emni.insert(2);
            arr[c] = 2;
          } else {
            emni.insert(3);
            arr[c] = 3;
          }
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      cout << arr[i];
      if (i != n)
        cout << " ";
      else
        cout << "\n";
    }
  }
  return 0;
}
