#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, ma, a, b, c, f1, f2, f3, i;
  cin >> n >> ma;
  map<int, int> m;
  while (ma--) {
    cin >> a >> b >> c;
    f1 = 0, f2 = 0, f3 = 0;
    if (m[a] == 0) f1 = 1;
    if (m[b] == 0) f2 = 1;
    if (m[c] == 0) f3 = 1;
    if (f1 == 1) {
      if (m[b] != 1 && m[c] != 1)
        m[a] = 1;
      else if (m[b] != 2 && m[c] != 2)
        m[a] = 2;
      else
        m[a] = 3;
    }
    if (f2 == 1) {
      if (m[a] != 1 && m[c] != 1)
        m[b] = 1;
      else if (m[a] != 2 && m[c] != 2)
        m[b] = 2;
      else
        m[b] = 3;
    }
    if (f3 == 1) {
      if (m[b] != 1 && m[a] != 1)
        m[c] = 1;
      else if (m[b] != 2 && m[a] != 2)
        m[c] = 2;
      else
        m[c] = 3;
    }
  }
  for (i = 1; i <= n; i++) cout << m[i] << " ";
  cout << endl;
}
