#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int c[maxn];
int M[4][2] = {{0, 0}, {2, 3}, {1, 3}, {1, 2}};
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  int x, y, z;
  memset(c, 0, sizeof(c));
  scanf("%d %d", &n, &m);
  while (m--) {
    scanf("%d %d %d", &x, &y, &z);
    if (c[x]) {
      c[y] = M[c[x]][0];
      c[z] = M[c[x]][1];
    } else if (c[y]) {
      c[x] = M[c[y]][0];
      c[z] = M[c[y]][1];
    } else if (c[z]) {
      c[x] = M[c[z]][0];
      c[y] = M[c[z]][1];
    } else {
      c[x] = 1;
      c[y] = 2;
      c[z] = 3;
    }
  }
  for (int i = 1; i < n + 1; ++i) printf("%d ", c[i]);
  putchar('\n');
  return 0;
}
