#include <bits/stdc++.h>
int ar[100005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int x, y, z;
  for (int i = 0; i < m; i++) {
    int sum = 0;
    scanf("%d %d %d", &x, &y, &z);
    int c;
    c = 0;
    if (ar[x] == 0) c++;
    if (ar[y] == 0) c++;
    if (ar[z] == 0) c++;
    if (c == 3) {
      ar[x] = 1;
      ar[y] = 2;
      ar[z] = 3;
    } else if (ar[x] == 0 && c == 1)
      ar[x] = 6 - ar[y] - ar[z];
    else if (c == 1 && ar[z] == 0)
      ar[z] = 6 - ar[x] - ar[y];
    else if (ar[y] == 0 && c == 1)
      ar[y] = 6 - ar[x] - ar[z];
    else if (c == 2) {
      sum = ar[x] + ar[y] + ar[z];
      if (sum == 1) {
        if (ar[x] != 0) {
          ar[y] = 2;
          ar[z] = 3;
        } else if (ar[y] != 0) {
          ar[x] = 2;
          ar[z] = 3;
        } else if (ar[z] != 0) {
          ar[x] = 2;
          ar[y] = 3;
        }
      } else if (sum == 2) {
        if (ar[x] != 0) {
          ar[y] = 1;
          ar[z] = 3;
        } else if (ar[y] != 0) {
          ar[x] = 1;
          ar[z] = 3;
        } else if (ar[z] != 0) {
          ar[x] = 1;
          ar[y] = 3;
        }
      } else if (sum == 3) {
        if (ar[x] != 0) {
          ar[y] = 1;
          ar[z] = 2;
        } else if (ar[y] != 0) {
          ar[x] = 1;
          ar[z] = 2;
        } else if (ar[z] != 0) {
          ar[x] = 1;
          ar[y] = 2;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", ar[i]);
  printf("\n");
  return 0;
}
