#include <bits/stdc++.h>
using namespace std;
long n, m;
int d[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long i = 1; i <= m; i++) {
    long a[4];
    for (int j = 1; j <= 3; j++) cin >> a[j];
    int minorCheck[4] = {0};
    for (int j = 1; j <= 3; j++)
      if (d[a[j]] != 0) {
        minorCheck[d[a[j]]] = 1;
        continue;
      }
    for (int j = 1; j <= 3; j++) {
      if (d[a[j]] != 0) continue;
      for (int k = 1; k <= 3; k++)
        if (!minorCheck[k]) {
          d[a[j]] = k;
          minorCheck[k] = 1;
          break;
        }
    }
  }
  for (long i = 1; i <= n; i++) cout << d[i] << ' ';
  return 0;
}
