#include <bits/stdc++.h>
using namespace std;
long i, n, m, a, b, c, cl[120000];
int main() {
  while (scanf("%ld%ld", &n, &m) == 2) {
    for (i = 0; i <= n; i++) cl[i] = -1;
    for (i = 0; i < m; i++) {
      scanf("%ld%ld%ld", &a, &b, &c);
      if (cl[a] != -1) {
        cl[b] = (cl[a] + 1) % 3;
        cl[c] = (cl[a] + 2) % 3;
      } else if (cl[b] != -1) {
        cl[a] = (cl[b] + 1) % 3;
        cl[c] = (cl[b] + 2) % 3;
      } else if (cl[c] != -1) {
        cl[a] = (cl[c] + 1) % 3;
        cl[b] = (cl[c] + 2) % 3;
      } else {
        cl[a] = 0;
        cl[b] = 1;
        cl[c] = 2;
      }
    }
    for (i = 1; i < n; i++) printf("%ld ", cl[i] + 1);
    printf("%ld\n", cl[n] + 1);
  }
  return 0;
}
