#include <bits/stdc++.h>
using namespace std;
int m, n, i, x, y, z;
int main() {
  cin >> m >> n;
  int check[m], color[m];
  int j;
  for (i = 0; i < m; i++) {
    check[i] = 0;
  }
  for (i = 0; i < n; i++) {
    cin >> x >> y >> z;
    x--;
    y--;
    z--;
    int fil;
    if (check[x] == 0 && check[y] == 0 && check[z] == 0) {
      check[x] = 1;
      check[y] = 1;
      check[z] = 1;
      color[x] = 0;
      color[y] = 1;
      color[z] = 2;
    } else if (check[x] == 1) {
      check[y] = 1;
      check[z] = 1;
      fil = color[x];
      color[y] = (fil + 1) % 3;
      color[z] = (fil + 2) % 3;
    } else if (check[y] == 1) {
      check[x] = 1;
      check[z] = 1;
      fil = color[y];
      color[x] = (fil + 1) % 3;
      color[z] = (fil + 2) % 3;
    } else if (check[z] == 1) {
      check[y] = 1;
      check[x] = 1;
      fil = color[z];
      color[y] = (fil + 1) % 3;
      color[x] = (fil + 2) % 3;
    }
  }
  for (i = 0; i < m; i++) cout << color[i] + 1 << " ";
  return 0;
}
