#include <bits/stdc++.h>
using namespace std;
const double PI = std::atan(1.0) * 4;
int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> elems(n + 1, 0);
  for (int i = 0; i < m; ++i) {
    int aux = 0;
    vector<bool> colors(4, false);
    vector<int> nopaint;
    for (int j = 0; j < 3; ++j) {
      cin >> aux;
      if (elems[aux] != 0) {
        colors[elems[aux]] = true;
      } else {
        nopaint.push_back(aux);
      }
    }
    aux = 0;
    while (aux < nopaint.size()) {
      int k = 1;
      while (k <= 3 && colors[k]) {
        ++k;
      }
      elems[nopaint[aux]] = k;
      colors[k] = true;
      ++aux;
    }
  }
  cout << elems[1];
  for (int i = 2; i <= n; ++i) cout << " " << elems[i];
  cout << endl;
  return EXIT_SUCCESS;
}
