#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long mod = 1e6 + 3;
int solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > mat(m, vector<long long int>(3, 0));
  for (long long int i = 0; i < m; i++)
    for (long long int j = 0; j < 3; j++) cin >> mat[i][j];
  vector<long long int> ans(n, -1);
  for (long long int i = 0; i < m; i++) {
    vector<long long int> a = mat[i];
    set<long long> col;
    for (long long int j = 1; j < 4; j++) col.insert(j);
    for (long long int j = 0; j < 3; j++)
      if (ans[a[j] - 1] != -1) col.erase(ans[a[j] - 1]);
    for (long long int j = 0; j < 3; j++)
      if (ans[a[j] - 1] == -1)
        ans[a[j] - 1] = *col.begin(), col.erase(ans[a[j] - 1]);
  }
  for (long long int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
int main() {
  auto start = chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long test_cases = 1;
  while (test_cases--) solve();
  auto stop = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
}
