#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[5];
int x[200000];
int main() {
  cin >> n >> m;
  memset(x, 0, sizeof(x));
  for (int i = 1; i <= m; i++) {
    int flag = 0;
    for (int j = 1; j <= 3; j++) cin >> a[j];
    for (int j = 1; j <= 3; j++)
      if (x[a[j]] != 0) flag = j;
    if (flag == 0)
      for (int j = 1; j <= 3; j++) x[a[j]] = j;
    if (flag == 1) {
      x[a[2]] = x[a[flag]] + 1;
      x[a[3]] = x[a[flag]] + 2;
    }
    if (flag == 2) {
      x[a[1]] = x[a[flag]] + 2;
      x[a[3]] = x[a[flag]] + 1;
    }
    if (flag == 3) {
      x[a[2]] = x[a[flag]] + 1;
      x[a[1]] = x[a[flag]] + 2;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (x[i] % 3 == 0)
      x[i] = 3;
    else
      x[i] = x[i] % 3;
  }
  for (int i = 1; i <= n; i++) cout << x[i] << " ";
}
