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