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