#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000000000000LL;
vector<int> gr[100005];
vector<int> vis(100005, -1);
vector<int> col(100005, -1);
void dfs(int u, int par, int col) {
  int i;
  col = (col ^ (vis[par] - 1));
  for (i = 0; i < 3; i++) {
    if ((col & (1 << i)) == 0) break;
  }
  vis[u] = i + 1;
  col = col | (1 << i);
  for (auto v : gr[u]) {
    if (vis[v] == -1) {
      dfs(v, u, col);
    }
  }
  return;
}
int coloring(int u, int n) {
  if (u == n + 1) return 1;
  vector<int> avail(4, 1);
  for (auto v : gr[u]) {
    if (v < u) {
      avail[col[v]] = 0;
    }
  }
  for (int j = 1; j <= 3; j++) {
    if (avail[j] == 1) {
      col[u] = j;
      if (coloring(u + 1, n) == 1) return 1;
      col[u] = -1;
    }
  }
  return 0;
}
int main() {
  int n, m, i, j, x, y, z;
  vector<int> tmp(4, 1);
  vector<int> avail;
  cin >> n >> m;
  while (m--) {
    avail = tmp;
    cin >> x >> y >> z;
    if (col[x] != -1) avail[col[x]] = 0;
    if (col[y] != -1) avail[col[y]] = 0;
    if (col[z] != -1) avail[col[z]] = 0;
    if (col[x] == -1) {
      for (i = 1; i <= 3; i++) {
        if (avail[i] == 1) {
          col[x] = i;
          avail[i] = 0;
          break;
        }
      }
    }
    if (col[y] == -1) {
      for (i = 1; i <= 3; i++) {
        if (avail[i] == 1) {
          col[y] = i;
          avail[i] = 0;
          break;
        }
      }
    }
    if (col[z] == -1) {
      for (i = 1; i <= 3; i++) {
        if (avail[i] == 1) {
          col[z] = i;
          avail[i] = 0;
          break;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << " " << col[i];
  }
  cout << "\n";
  return 0;
}
