#include <bits/stdc++.h>
using namespace std;
long long n, k;
struct mang {
  long long a;
  long long b;
  long long c;
} m[100006];
long long check[100005];
bool operator<(mang u, mang v) { return u.a < v.a; }
void xuly(long long a, long long b, long long c) {
  if (check[b] == 0 && check[c] == 0) {
    check[a] = 1;
  } else if (check[b] == 1 && check[c] == 0) {
    check[a] = 2;
  } else if (check[b] == 2 && check[c] == 0) {
    check[a] = 3;
  } else if (check[b] == 3 && check[c] == 0) {
    check[a] = 2;
  } else if (check[c] == 1 && check[b] == 0) {
    check[a] = 2;
  } else if (check[c] == 2 && check[b] == 0) {
    check[a] = 3;
  } else if (check[c] == 3 && check[b] == 0) {
    check[a] = 2;
  } else if (check[b] == 1 && check[c] == 2) {
    check[a] = 3;
  } else if (check[b] == 1 && check[c] == 3) {
    check[a] = 2;
  } else if (check[b] == 2 && check[c] == 3) {
    check[a] = 1;
  } else if (check[c] == 1 && check[b] == 2) {
    check[a] = 3;
  } else if (check[c] == 1 && check[b] == 3) {
    check[a] = 2;
  } else if (check[c] == 2 && check[b] == 3) {
    check[a] = 1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) check[i] = 0;
  for (long long i = 1; i <= k; i++) {
    cin >> m[i].a;
    cin >> m[i].b;
    cin >> m[i].c;
  }
  for (long long i = 1; i <= k; i++) {
    if (check[m[i].a] == 0) xuly(m[i].a, m[i].b, m[i].c);
    if (check[m[i].b] == 0) xuly(m[i].b, m[i].a, m[i].c);
    if (check[m[i].c] == 0) xuly(m[i].c, m[i].a, m[i].b);
  }
  for (long long i = 1; i <= n; i++) cout << check[i] << " ";
  return 0;
}
