#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9, mxn = 100010;
int color[mxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(color, -1, sizeof color);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    A[0]--;
    A[1]--;
    A[2]--;
    int i = 0;
    while (i < 3) {
      if (color[A[i]] != -1) {
        color[A[(i + 1) % 3]] = (color[A[i]] + 1) % 3;
        color[A[(i + 2) % 3]] = (color[A[i]] + 2) % 3;
        break;
      }
      i++;
    }
    if (i == 3) {
      for (int i = (0); i < (3); ++i) color[A[i]] = i;
    }
  }
  for (int i = (0); i < (n); ++i) cout << color[i] + 1 << " ";
  cout << '\n';
  return 0;
}
