#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-10L;
void fast_io() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast_io();
  int n, m;
  cin >> n >> m;
  int color[n + 1];
  memset(color, 0, sizeof(color));
  while (m--) {
    int x[3];
    bool visited[4];
    for (int i = 0; i <= 2; i++) cin >> x[i];
    memset(visited, 0, sizeof(visited));
    for (int i = 0; i <= 2; i++) {
      if (color[x[i]]) visited[color[x[i]]] = true;
    }
    for (int i = 0; i <= 2; i++)
      if (!color[x[i]]) {
        int val = 1;
        while (visited[val]) val++;
        color[x[i]] = val;
        visited[val] = true;
      }
  }
  for (int i = 1; i <= n; i++) cout << color[i] << ' ';
  cout << '\n';
  return 0;
}
