#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
template <class T>
string i2s(T x) {
  ostringstream o;
  o << x;
  return o.str();
}
vector<string> splt(string s, char c = ' ') {
  vector<string> rv;
  int p = 0, np;
  while (np = s.find(c, p), np >= 0) {
    if (np != p) rv.push_back(s.substr(p, np - p));
    p = np + 1;
  }
  if (p < int((s).size())) rv.push_back(s.substr(p));
  return rv;
}
void print(vector<int> v, int sz = -1) {
  if (sz == -1) sz = int((v).size());
  cerr << "[";
  if (sz) cerr << v[0];
  for (int i = (1), _b = (sz); i < _b; ++i) cerr << ", " << v[i];
  cerr << "]" << endl;
}
void print(vector<double> v, int sz = -1) {
  if (sz == -1) sz = int((v).size());
  cerr << "[";
  if (sz) cerr << v[0];
  for (int i = (1), _b = (sz); i < _b; ++i) cerr << ", " << v[i];
  cerr << "]" << endl;
}
void print(vector<string> v, int sz = -1) {
  if (sz == -1) sz = int((v).size());
  cerr << "[";
  if (sz) cerr << v[0];
  for (int i = (1), _b = (sz); i < _b; ++i) cerr << ", " << v[i];
  cerr << "]" << endl;
}
void print(pair<int, int> v) {
  cerr << "{ " << v.first << ", " << v.second << " }";
}
void print(vector<pair<int, int> > v, int sz = -1) {
  if (sz == -1) sz = int((v).size());
  cerr << "[ ";
  if (sz) print(v[0]);
  for (int i = (1), _b = (sz); i < _b; ++i) {
    cerr << ", ";
    print(v[i]);
  }
  cerr << "]" << endl;
}
void print(vector<vector<int> > v, int sz1 = -1, int sz2 = -1) {
  if (sz1 == -1) sz1 = int((v).size());
  if (sz2 == -1) sz2 = int((v[0]).size());
  cerr << "[ ---" << endl;
  if (sz1) cerr << " ", print(v[0], sz2);
  for (int i = (1), _b = (sz1); i < _b; ++i) cerr << " ", print(v[i], sz2);
  cerr << "--- ]\n";
}
const double EPS = 1e-9;
const int MOD = int(1e9) + 7;
const double PI = acos(-1.0);
void pre() {}
int main() {
  pre();
  int n, m;
  cin >> n >> m;
  int A[100005], B[100005], C[100005];
  for (int _n = m, i = 0; i < _n; ++i) cin >> A[i] >> B[i] >> C[i];
  int re[100005];
  for (int _n = n, i = 0; i < _n; ++i) re[i] = -1;
  for (int _n = m, i = 0; i < _n; ++i) {
    int a, b, c;
    a = A[i] - 1;
    b = B[i] - 1;
    c = C[i] - 1;
    vector<pair<int, int> > v;
    v.push_back(make_pair(re[a], a));
    v.push_back(make_pair(re[b], b));
    v.push_back(make_pair(re[c], c));
    sort((v).begin(), (v).end());
    if (v[2].first == -1) {
      re[v[0].second] = 1;
      re[v[1].second] = 2;
      re[v[2].second] = 3;
    } else if (v[1].first == -1) {
      if (v[2].first == 1) {
        re[v[0].second] = 2;
        re[v[1].second] = 3;
      } else if (v[2].first == 2) {
        re[v[0].second] = 1;
        re[v[1].second] = 3;
      } else {
        re[v[0].second] = 1;
        re[v[1].second] = 2;
      }
    } else if (v[0].first == -1) {
      if (v[1].first == 1 && v[2].first == 2) {
        re[v[0].second] = 3;
      } else if (v[1].first == 1 && v[2].first == 3) {
        re[v[0].second] = 2;
      } else {
        re[v[0].second] = 1;
      }
    }
  }
  for (int _n = n, i = 0; i < _n; ++i) cout << re[i] << " ";
  cout << endl;
  return 0;
}
