#include <bits/stdc++.h>
using namespace std;
int color[100005];
int main() {
  int n, m;
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (color[a] == 0 && color[b] == 0 && color[c] == 0) {
      color[a] = 1;
      color[b] = 2;
      color[c] = 3;
    } else if (color[a] == 1) {
      color[b] = 2;
      color[c] = 3;
    } else if (color[a] == 2) {
      color[b] = 1;
      color[c] = 3;
    } else if (color[a] == 3) {
      color[b] = 1;
      color[c] = 2;
    } else if (color[b] == 1) {
      color[a] = 2;
      color[c] = 3;
    } else if (color[b] == 2) {
      color[a] = 1;
      color[c] = 3;
    } else if (color[b] == 3) {
      color[a] = 2;
      color[c] = 1;
    } else if (color[c] == 1) {
      color[b] = 2;
      color[a] = 3;
    } else if (color[c] == 2) {
      color[b] = 1;
      color[a] = 3;
    } else if (color[c] == 3) {
      color[a] = 2;
      color[b] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << color[i] << " ";
  }
  return 0;
}
