#include <bits/stdc++.h>
using namespace std;
int N, M, Num[3], Ans[111111];
int main() {
  cin >> N >> M;
  for (int n = 1; n <= N; ++n) Ans[n] = -1;
  while (M--) {
    int d = 0, c = 0;
    for (int k = 0; k < 3; ++k) {
      cin >> Num[k];
      if (~Ans[Num[k]]) {
        d = k;
        c = Ans[Num[k]];
      }
    }
    for (int k = 0; k < 3; ++k) Ans[Num[(k + d) % 3]] = (c++) % 3;
  }
  for (int n = 1; n <= N; ++n) cout << Ans[n] + 1 << " ";
  return 0;
}
