#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> roupa(n + 1, 0);
  for (int i = 0; i < m; i++) {
    bool cor[4];
    memset(cor, false, 4);
    int d[3];
    for (int i = 0; i < 3; i++) {
      cin >> d[i];
      cor[roupa[d[i]]] = true;
    }
    for (int i = 0; i < 3; i++) {
      if (roupa[d[i]] == 0) {
        for (int j = 1; j < 4; j++) {
          if (!cor[j]) {
            roupa[d[i]] = j;
            cor[j] = true;
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << roupa[i + 1] << " ";
  }
  cout << endl;
  return 0;
}
