#include <bits/stdc++.h>
using namespace std;
int main() {
  int dancers, dances;
  int a, b, c;
  cin >> dancers >> dances;
  int arr[100010] = {0};
  for (int i = 0; i < dances; i++) {
    cin >> a >> b >> c;
    int colrs = arr[a] + arr[b] + arr[c];
    if (arr[a] == 0) {
      colrs++;
      colrs = colrs % 3;
      if (colrs == 0) {
        colrs = 3;
      }
      arr[a] = colrs;
    }
    if (arr[b] == 0) {
      colrs++;
      colrs = colrs % 3;
      if (colrs == 0) {
        colrs = 3;
      }
      arr[b] = colrs;
    }
    if (arr[c] == 0) {
      colrs++;
      colrs = colrs % 3;
      if (colrs == 0) {
        colrs = 3;
      }
      arr[c] = colrs;
    }
  }
  for (int i = 1; i <= dancers; i++) {
    cout << arr[i] << " ";
  }
  return 0;
}
