#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
void debugarr(int* arr, int n) {
  cout << "[";
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
void debugvec(vector<int> arr) {
  cout << "[";
  for (int i = 0; i < ((int)(arr.size())); i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
vector<int> n[100000];
int m[100000][3];
int tridone[100000] = {0};
int ans[100000];
void dfs(int x) {
  vector<int> tri = n[x];
  for (int i = 0; i < tri.size(); i++) {
    if (tridone[tri[i]]) continue;
    tridone[tri[i]] = 1;
    int ind;
    if (m[tri[i]][0] == x)
      ind = 0;
    else if (m[tri[i]][1] == x)
      ind = 1;
    else
      ind = 2;
    ans[m[tri[i]][(ind + 1) % 3]] = (ans[x] + 1) % 3;
    ans[m[tri[i]][(ind + 2) % 3]] = (ans[x] + 2) % 3;
    dfs(m[tri[i]][(ind + 1) % 3]);
    dfs(m[tri[i]][(ind + 2) % 3]);
  }
  return;
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> m[i][0] >> m[i][1] >> m[i][2];
    m[i][0]--;
    m[i][1]--;
    m[i][2]--;
    n[m[i][0]].push_back(i);
    n[m[i][1]].push_back(i);
    n[m[i][2]].push_back(i);
  }
  for (int i = 0; i < N; i++) {
    ans[i] = -1;
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] != -1) continue;
    ans[i] = 0;
    dfs(i);
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
