#include <bits/stdc++.h>
using namespace std;
bool isprime(long long int n) {
  if (n < 2) return false;
  for (long long int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
long long gcd(long long int a, long long int b) {
  if (a == 0 || b == 0)
    return a + b;
  else
    return gcd(b, a % b);
}
void MAIN();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  MAIN();
  return 0;
}
int cnt[100001];
void MAIN() {
  int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (cnt[a] > 0) {
      int num = cnt[a];
      if (num == 1) {
        cnt[b] = 2;
        cnt[c] = 3;
      } else if (num == 2) {
        cnt[b] = 1;
        cnt[c] = 3;
      } else {
        cnt[b] = 1;
        cnt[c] = 2;
      }
    } else if (cnt[b] > 0) {
      int num = cnt[b];
      if (num == 1) {
        cnt[a] = 2;
        cnt[c] = 3;
      } else if (num == 2) {
        cnt[a] = 1;
        cnt[c] = 3;
      } else {
        cnt[a] = 1;
        cnt[c] = 2;
      }
    } else if (cnt[c] > 0) {
      int num = cnt[c];
      if (num == 1) {
        cnt[a] = 2;
        cnt[b] = 3;
      } else if (num == 2) {
        cnt[a] = 1;
        cnt[b] = 3;
      } else {
        cnt[a] = 1;
        cnt[b] = 2;
      }
    } else {
      cnt[a] = 1;
      cnt[b] = 2;
      cnt[c] = 3;
    }
  }
  for (long long int i = 1; i <= n; i++) cout << cnt[i] << ' ';
}
