#include <bits/stdc++.h>
using namespace std;
struct Dance {
  long long a, b, c;
};
void solve() {
  long long i, j, k;
  long long n, m;
  cin >> n >> m;
  vector<Dance> dances(m);
  for (i = (0); i < (m); i++) cin >> dances[i].a >> dances[i].b >> dances[i].c;
  vector<long long> colors(n + 1);
  vector<bool> visited(n + 1, false);
  for (i = (0); i < (m); i++) {
    long long occupied = -1, occpos = -1;
    if (visited[dances[i].a]) {
      occupied = colors[dances[i].a];
      occpos = 0;
    }
    if (visited[dances[i].b]) {
      occupied = colors[dances[i].b];
      occpos = 1;
    }
    if (visited[dances[i].c]) {
      occupied = colors[dances[i].c];
      occpos = 2;
    }
    if (occupied == -1) {
      colors[dances[i].a] = 0;
      colors[dances[i].b] = 1;
      colors[dances[i].c] = 2;
      visited[dances[i].a] = true;
      visited[dances[i].b] = true;
      visited[dances[i].c] = true;
    } else {
      long long first, second;
      if (occpos == 0) {
        first = 1;
        second = 2;
      }
      if (occpos == 1) {
        first = 0;
        second = 2;
      }
      if (occpos == 2) {
        first = 0;
        second = 1;
      }
      if (occupied == 0) {
        if (first == 0) colors[dances[i].a] = 1;
        if (first == 1) colors[dances[i].b] = 1;
        if (first == 2) colors[dances[i].c] = 1;
        if (second == 0) colors[dances[i].a] = 2;
        if (second == 1) colors[dances[i].b] = 2;
        if (second == 2) colors[dances[i].c] = 2;
      } else if (occupied == 1) {
        if (first == 0) colors[dances[i].a] = 0;
        if (first == 1) colors[dances[i].b] = 0;
        if (first == 2) colors[dances[i].c] = 0;
        if (second == 0) colors[dances[i].a] = 2;
        if (second == 1) colors[dances[i].b] = 2;
        if (second == 2) colors[dances[i].c] = 2;
      } else if (occupied == 2) {
        if (first == 0) colors[dances[i].a] = 0;
        if (first == 1) colors[dances[i].b] = 0;
        if (first == 2) colors[dances[i].c] = 0;
        if (second == 0) colors[dances[i].a] = 1;
        if (second == 1) colors[dances[i].b] = 1;
        if (second == 2) colors[dances[i].c] = 1;
      }
      if (first == 0) visited[dances[i].a] = true;
      if (first == 1) visited[dances[i].b] = true;
      if (first == 2) visited[dances[i].c] = true;
      if (second == 0) visited[dances[i].a] = true;
      if (second == 1) visited[dances[i].b] = true;
      if (second == 2) visited[dances[i].c] = true;
    }
  }
  for (i = (1); i < (n + 1); i++) cout << (colors[i] + 1) << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
