#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = atan(1.0) * 4.0;
const long long mod = 1e9 + 7;
int n, m, c[SIZE], a[3];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> m;
  while (m--) {
    set<int> s;
    cin >> a[0] >> a[1] >> a[2];
    int t = c[a[0]] + c[a[1]] + c[a[2]];
    if (!t) {
      c[a[0]] = 1;
      c[a[1]] = 2;
      c[a[2]] = 3;
      continue;
    }
    s.insert(1), s.insert(2), s.insert(3);
    for (int i = 0; i < 3; i++)
      if (c[a[i]]) s.erase(c[a[i]]);
    for (int i = 0; i < 3; i++) {
      if (c[a[i]]) continue;
      c[a[i]] = (*s.begin());
      s.erase(s.begin());
    }
  }
  for (int i = 1; i <= n; i++) cout << c[i] << " ";
  return 0;
}
