#include <bits/stdc++.h>
using namespace std;
long long int ans[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, m;
  cin >> n >> m;
  long long int a[m][3];
  for (long long int i = 0; i < m; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
  for (long long int i = 0; i < m; i++) {
    if (ans[a[i][0]] != 0) {
      ans[a[i][1]] = ans[a[i][0]] % 3 + 1;
      ans[a[i][2]] = ans[a[i][1]] % 3 + 1;
    } else if (ans[a[i][1]] != 0) {
      ans[a[i][2]] = ans[a[i][1]] % 3 + 1;
      ans[a[i][0]] = ans[a[i][2]] % 3 + 1;
    } else {
      if (ans[a[i][2]] == 0) ans[a[i][2]] = 1;
      ans[a[i][0]] = ans[a[i][2]] % 3 + 1;
      ans[a[i][1]] = ans[a[i][0]] % 3 + 1;
    }
  }
  for (long long int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
