#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n >> m;
  int* col = new int[n + 1];
  fill_n(col, n + 1, 0);
  int a[3];
  int taken[4];
  for (long i = 0; i < m; i++) {
    cin >> a[0] >> a[1] >> a[2];
    fill_n(taken, 4, 0);
    for (int j = 0; j < 3; j++) taken[col[a[j]]]++;
    for (int j = 0; j < 3; j++)
      if (col[a[j]] == 0) {
        for (int k = 1; k <= 3; k++)
          if (taken[k] == 0) {
            taken[k] = 1;
            col[a[j]] = k;
            break;
          }
      }
  }
  for (long i = 1; i <= n; i++) cout << col[i] << " ";
  cout << endl;
  delete[] col;
  return 0;
}
