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