#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005], b[100005], x[100];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x[1] >> x[2] >> x[3];
    b[x[1]]++;
    b[x[2]]++;
    b[x[3]]++;
    if (b[x[1]] >= 2)
      swap(x[1], x[a[x[1]]]);
    else if (b[x[2]] >= 2)
      swap(x[2], x[a[x[2]]]);
    else if (b[x[3]] >= 2)
      swap(x[3], x[a[x[3]]]);
    a[x[1]] = 1;
    a[x[2]] = 2;
    a[x[3]] = 3;
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
