#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a[400005], n, m, x, y, z;
  memset(a, 0, sizeof(a));
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    if (a[x] != 1 && a[y] != 1 && a[z] != 1) {
      if (a[x] == 0)
        a[x] = 1;
      else if (a[y] == 0)
        a[y] = 1;
      else
        a[z] = 1;
    }
    if (a[x] != 2 && a[y] != 2 && a[z] != 2) {
      if (a[x] == 0)
        a[x] = 2;
      else if (a[y] == 0)
        a[y] = 2;
      else
        a[z] = 2;
    }
    if (a[x] != 3 && a[y] != 3 && a[z] != 3) {
      if (a[x] == 0)
        a[x] = 3;
      else if (a[y] == 0)
        a[y] = 3;
      else
        a[z] = 3;
    }
  }
  for (long long int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
