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