#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ma;
  cin >> n >> ma;
  int arr[ma][3];
  for (int i = 0; i < ma; i++)
    for (int j = 0; j < 3; j++) cin >> arr[i][j];
  map<int, int> m;
  m[arr[0][0]] = 1;
  m[arr[0][1]] = 2;
  m[arr[0][2]] = 3;
  for (int i = 1; i < ma; i++) {
    int index;
    for (int j = 0; j < 3; j++) {
      if (m[arr[i][j]] > 0) {
        index = m[arr[i][j]];
        m[arr[i][(j + 1) % 3]] = (index) % 3 + 1;
        index++;
        m[arr[i][(j + 2) % 3]] = (index) % 3 + 1;
        break;
      } else
        m[arr[i][j]] = j + 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << m[i] << " ";
  }
}
