#include <bits/stdc++.h>
using namespace std;
struct dance {
  int d[3];
};
int main() {
  int n, m, col[100001] = {0};
  dance dances[100000];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> dances[i].d[j];
    }
  }
  for (int i = 0; i < m; i++) {
    if (col[dances[i].d[0]] == 0 && col[dances[i].d[1]] == 0 &&
        col[dances[i].d[2]] == 0) {
      col[dances[i].d[0]] = 1;
      col[dances[i].d[1]] = 2;
      col[dances[i].d[2]] = 3;
    } else {
      if (col[dances[i].d[0]] != 0) {
        switch (col[dances[i].d[0]]) {
          case 1:
            col[dances[i].d[1]] = 2;
            col[dances[i].d[2]] = 3;
            break;
          case 2:
            col[dances[i].d[1]] = 1;
            col[dances[i].d[2]] = 3;
            break;
          case 3:
            col[dances[i].d[1]] = 1;
            col[dances[i].d[2]] = 2;
            break;
        }
      } else if (col[dances[i].d[1]] != 0) {
        switch (col[dances[i].d[1]]) {
          case 1:
            col[dances[i].d[0]] = 2;
            col[dances[i].d[2]] = 3;
            break;
          case 2:
            col[dances[i].d[0]] = 1;
            col[dances[i].d[2]] = 3;
            break;
          case 3:
            col[dances[i].d[0]] = 1;
            col[dances[i].d[2]] = 2;
            break;
        }
      } else if (col[dances[i].d[2]] != 0) {
        switch (col[dances[i].d[2]]) {
          case 1:
            col[dances[i].d[0]] = 2;
            col[dances[i].d[1]] = 3;
            break;
          case 2:
            col[dances[i].d[0]] = 1;
            col[dances[i].d[1]] = 3;
            break;
          case 3:
            col[dances[i].d[0]] = 1;
            col[dances[i].d[1]] = 2;
            break;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << col[i] << " ";
  }
  return 0;
}
