#include <bits/stdc++.h>
using namespace std;
int c[200000], n, m, a[10];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= 3; j++) scanf("%d", &a[j]);
    if (i == 1) {
      for (int j = 1; j <= 3; j++) c[a[j]] = j;
    } else {
      bool b[10];
      memset(b, 0, sizeof(b));
      for (int j = 1; j <= 3; j++) {
        if (c[a[j]]) b[c[a[j]]] = 1;
      }
      for (int j = 1; j <= 3; j++)
        if (!c[a[j]]) {
          for (int k = 1; k <= 3; k++)
            if (!b[k]) {
              c[a[j]] = k;
              b[k] = 1;
              break;
            }
        }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", c[i]);
}
