#include <bits/stdc++.h>
using namespace std;
int a[300001], b[300001], i, j, k, ctr, m, n, sum1 = 0, sum = 0, x, y;
int main() {
  cin >> n >> m;
  for (i = 0; i < 3 * m; i++) cin >> a[i];
  b[a[0]] = 1;
  b[a[1]] = 2;
  b[a[2]] = 3;
  for (i = 3; i < 3 * m; i = i + 3) {
    if (b[a[i]] == 0 && b[a[i + 1]] == 0 && b[a[i + 2]] == 0) {
      b[a[i]] = 1;
      b[a[i + 1]] = 2;
      b[a[i + 2]] = 3;
    } else if (b[a[i]] != 0 && b[a[i + 1]] == 0 && b[a[i + 2]] == 0) {
      if (b[a[i]] == 1) {
        b[a[i + 1]] = 2;
        b[a[i + 2]] = 3;
      } else if (b[a[i]] == 2) {
        b[a[i + 1]] = 1;
        b[a[i + 2]] = 3;
      } else {
        b[a[i + 1]] = 2;
        b[a[i + 2]] = 1;
      }
    } else if (b[a[i]] == 0 && b[a[i + 1]] != 0 && b[a[i + 2]] == 0) {
      if (b[a[i + 1]] == 1) {
        b[a[i]] = 2;
        b[a[i + 2]] = 3;
      } else if (b[a[i + 1]] == 2) {
        b[a[i]] = 1;
        b[a[i + 2]] = 3;
      } else {
        b[a[i]] = 2;
        b[a[i + 2]] = 1;
      }
    } else if (b[a[i]] == 0 && b[a[i + 1]] == 0 && b[a[i + 2]] != 0) {
      if (b[a[i + 2]] == 1) {
        b[a[i + 1]] = 2;
        b[a[i]] = 3;
      } else if (b[a[i + 2]] == 2) {
        b[a[i + 1]] = 1;
        b[a[i]] = 3;
      } else {
        b[a[i + 1]] = 2;
        b[a[i]] = 1;
      }
    }
  }
  for (i = 1; i <= n; i++) cout << b[i] << " ";
  return 0;
}
