#include <bits/stdc++.h>
using namespace std;
long long tests;
long long n, k, a, b, c, p[1000256];
void solve() {
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cin >> a >> b >> c;
    if (p[a]) {
      p[b] = 1 + p[a] % 3;
      p[c] = 1 + (1 + p[a] % 3) % 3;
    } else if (p[b]) {
      p[a] = 1 + p[b] % 3;
      p[c] = 1 + (1 + p[b] % 3) % 3;
    } else if (p[c]) {
      p[a] = 1 + p[c] % 3;
      p[b] = 1 + (1 + p[c] % 3) % 3;
    } else {
      p[a] = 1;
      p[b] = 2;
      p[c] = 3;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << p[i] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  solve();
}
