#include <bits/stdc++.h>
using namespace std;
int col[100003];
signed main() {
  ifstream in("Text.txt");
  int n, m;
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (col[a] == 0) {
      for (int j = 1; j <= 3; j++) {
        if (j != col[b] && j != col[c]) {
          col[a] = j;
          break;
        }
      }
    }
    if (col[b] == 0) {
      for (int j = 1; j <= 3; j++) {
        if (j != col[a] && j != col[c]) {
          col[b] = j;
          break;
        }
      }
    }
    if (col[c] == 0) {
      for (int j = 1; j <= 3; j++) {
        if (j != col[b] && j != col[a]) {
          col[c] = j;
          break;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << max(col[i], 1) << " ";
  cout << endl;
  return 0;
}
