#include <bits/stdc++.h>
using namespace std;
int colors[100010];
int main() {
  int N, M;
  cin >> N >> M;
  for (size_t i = 0; i < N + 1; i++) colors[i] = 0;
  for (size_t i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (colors[a] != 0) {
      colors[b] = ((colors[a]) % 3) + 1;
      colors[c] = ((colors[a] + 1) % 3) + 1;
      continue;
    }
    if (colors[b] != 0) {
      colors[a] = ((colors[b]) % 3) + 1;
      colors[c] = ((colors[b] + 1) % 3) + 1;
      continue;
    }
    if (colors[c] != 0) {
      colors[a] = ((colors[c]) % 3) + 1;
      colors[b] = ((colors[c] + 1) % 3) + 1;
      continue;
    }
    colors[a] = 1;
    colors[b] = 2;
    colors[c] = 3;
  }
  for (size_t i = 0; i < N; i++) {
    cout << colors[i + 1] << " ";
  }
}
