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