#include <bits/stdc++.h>
using namespace std;
long long ans[100009] = {0};
bool set_col[100009];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long arr[3];
    long long setp = -1;
    for (long long j = 0; j < 3; j++) {
      cin >> arr[j];
      if (set_col[arr[j]] == true) setp = j;
    }
    if (setp == -1) ans[arr[0]] = 0, setp = 0, set_col[arr[0]] = true;
    for (long long i1 = 0; i1 < 2; i1++) {
      ans[arr[(setp + i1 + 1) % 3]] = (ans[arr[(setp + i1) % 3]] + 1) % 3;
      set_col[arr[(setp + i1 + 1) % 3]] = true;
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << ans[i + 1] + 1 << " ";
  }
}
