#include <bits/stdc++.h>
using namespace std;
int res[100001];
int main() {
  int n, m, a[100000][3], x, y;
  memset(res, -1, sizeof(res));
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < 3; j++) cin >> a[i][j];
  res[a[0][0]] = 1;
  res[a[0][1]] = 2;
  res[a[0][2]] = 3;
  for (int i = 1; i < m; i++) {
    x = 0;
    y = 0;
    for (int j = 0; j < 3; j++) {
      if (res[a[i][j]] != -1 && x == 0)
        x = res[a[i][j]];
      else if (res[a[i][j]] != -1 && y == 0)
        y = res[a[i][j]];
    }
    if (x == 0 && y == 0) {
      for (int j = 0; j < 3; j++) res[a[i][j]] = j + 1;
    } else
      for (int j = 0; j < 3; j++) {
        if (res[a[i][j]] == -1)
          if (x == 2 && y == 3 || x == 3 && y == 2)
            res[a[i][j]] = 1;
          else if (x == 1 && y == 3 || x == 3 && y == 1)
            res[a[i][j]] = 2;
          else if (x == 1 && y == 2 || x == 2 && y == 1)
            res[a[i][j]] = 3;
          else if ((x == 1 || x == 2) && y == 0) {
            res[a[i][j]] = 3;
            y = 3;
          } else if ((y == 1 || y == 2) && x == 0) {
            res[a[i][j]] = 3;
            x = 3;
          } else if (x == 3 && y == 0) {
            res[a[i][j]] = 1;
            y = 1;
          } else if (y == 3 && x == 0) {
            res[a[i][j]] = 1;
            x = 1;
          }
      }
  }
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
  return 0;
}
