#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  map<long long, long long> make_pair;
  for (long long i = 1; i < n; i++) {
    make_pair[i] = 0;
  }
  long long t1, t2, t3;
  for (long long i = 0; i < m; i++) {
    cin >> t1 >> t2 >> t3;
    if (make_pair[t1] != 0) {
      long long k = make_pair[t1];
      make_pair[t2] = k + 1 > 3 ? (k + 1) % 3 : k + 1;
      make_pair[t3] = k + 2 > 3 ? (k + 2) % 3 : k + 2;
    } else if (make_pair[t2] != 0) {
      long long k = make_pair[t2];
      make_pair[t1] = k + 1 > 3 ? (k + 1) % 3 : k + 1;
      make_pair[t3] = k + 2 > 3 ? (k + 2) % 3 : k + 2;
    } else if (make_pair[t3] != 0) {
      long long k = make_pair[t3];
      make_pair[t2] = k + 1 > 3 ? (k + 1) % 3 : k + 1;
      make_pair[t1] = k + 2 > 3 ? (k + 2) % 3 : k + 2;
    } else {
      make_pair[t1] = 1;
      make_pair[t2] = 2;
      make_pair[t3] = 3;
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << make_pair[i] << " ";
  }
  cout << "\n";
  return 0;
}
