#include <bits/stdc++.h>
using namespace std;
struct arr {
  int f, s, t;
} ar[100005];
int ans[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, a, b, c, br[4];
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> br[1] >> br[2] >> br[3];
    sort(br + 1, br + 1 + 3);
    ar[i].f = br[1], ar[i].s = br[2], ar[i].t = br[3];
  }
  for (int i = 1; i <= m; i++) {
    memset(br, 0, sizeof br);
    if (ans[ar[i].f]) br[ans[ar[i].f]] = 1;
    if (ans[ar[i].s]) br[ans[ar[i].s]] = 1;
    if (ans[ar[i].t]) br[ans[ar[i].t]] = 1;
    if (!ans[ar[i].f]) {
      for (int j = 1; j <= 3; j++) {
        if (!br[j]) {
          ans[ar[i].f] = j, br[j] = 1;
          break;
        }
      }
    }
    if (!ans[ar[i].s]) {
      for (int j = 1; j <= 3; j++) {
        if (!br[j]) {
          ans[ar[i].s] = j, br[j] = 1;
          break;
        }
      }
    }
    if (!ans[ar[i].t]) {
      for (int j = 1; j <= 3; j++) {
        if (!br[j]) {
          ans[ar[i].t] = j, br[j] = 1;
          break;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
