#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long mod = 1e9 + 7;
void sout() { cout << "\n"; }
template <typename T, typename... Types>
void sout(T var1, Types... var2) {
  cout << var1 << " ";
  sout(var2...);
}
long long n, m;
long long temp;
long long cnt;
long long ans;
long long ind;
void test_case() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  long long arr[m][3];
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < 3; j++) {
      cin >> arr[i][j];
    }
  }
  map<long long, long long> mp;
  for (auto it : arr) {
    set<long long> temp;
    for (long long i = 0; i < 3; i++) {
      temp.insert(it[i]);
    }
    set<long long> st;
    st.insert(1);
    st.insert(2);
    st.insert(3);
    for (auto it : temp) {
      if (mp.find(it) != mp.end()) {
        st.erase(mp[it]);
      }
    }
    for (auto it : temp) {
      if (mp.find(it) == mp.end()) {
        mp[it] = *st.begin();
        st.erase(st.begin());
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << mp[i] << " ";
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) {
    test_case();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
