#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  int x1, x2, x3;
  cin >> n >> m;
  int a[n];
  for (i = 1; i <= n; i++) a[i] = 0;
  for (i = 1; i <= m; i++) {
    cin >> x1 >> x2 >> x3;
    if (a[x1] == 0 && a[x2] == 0 && a[x3] == 0) {
      a[x1] = 1;
      a[x2] = 2;
      a[x3] = 3;
    } else if (a[x1] != 0) {
      if (a[x1] == 1) {
        a[x2] = 2;
        a[x3] = 3;
        continue;
      }
      if (a[x1] == 2) {
        a[x2] = 1;
        a[x3] = 3;
        continue;
      }
      if (a[x1] == 3) {
        a[x2] = 2;
        a[x3] = 1;
        continue;
      }
    } else if (a[x2] != 0) {
      if (a[x2] == 1) {
        a[x1] = 2;
        a[x3] = 3;
        continue;
      }
      if (a[x2] == 2) {
        a[x1] = 1;
        a[x3] = 3;
        continue;
      }
      if (a[x2] == 3) {
        a[x1] = 2;
        a[x3] = 1;
        continue;
      }
    } else if (a[x3] != 0) {
      if (a[x3] == 1) {
        a[x2] = 2;
        a[x1] = 3;
        continue;
      }
      if (a[x3] == 2) {
        a[x2] = 1;
        a[x1] = 3;
        continue;
      }
      if (a[x3] == 3) {
        a[x2] = 2;
        a[x1] = 1;
        continue;
      }
    }
  }
  for (i = 1; i <= n; i++) cout << a[i] << " ";
}
