#include <bits/stdc++.h>
using namespace std;
int vec[100010];
int main() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  bool usado[3];
  memset(vec, 0, sizeof(vec));
  for (int i = 0; i < m; i++) {
    vector<int> pila;
    memset(usado, false, sizeof usado);
    int a, b, c;
    scanf("%d %d %d\n", &a, &b, &c);
    if (vec[a - 1] != 0)
      usado[vec[a - 1] - 1] = true;
    else {
      pila.push_back(a - 1);
    }
    if (vec[b - 1] != 0)
      usado[vec[b - 1] - 1] = true;
    else {
      pila.push_back(b - 1);
    }
    if (vec[c - 1] != 0)
      usado[vec[c - 1] - 1] = true;
    else {
      pila.push_back(c - 1);
    }
    int indice = 0;
    for (int i = 0; i < 3; i++) {
      if (usado[i] == false) {
        vec[pila[indice]] = i + 1;
        indice++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", vec[i]);
  }
  return 0;
}
