#include <bits/stdc++.h>
using namespace std;
int n, m;
int color[111111];
int d[111111][3];
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) scanf("%d", &d[i][j]);
  }
  for (int i = 0; i < n; i++) {
    int ok[3] = {};
    int exist = 0;
    for (int j = 0; j < 3; j++) {
      int cur = d[i][j];
      if (color[cur]) {
        exist = 1;
        ok[color[cur] - 1] = 1;
        break;
      }
    }
    if (exist) {
      for (int j = 0; j < 3; j++) {
        int cur = d[i][j];
        if (color[cur]) continue;
        for (int k = 0; k < 3; k++) {
          if (!ok[k]) {
            ok[k] = 1;
            color[cur] = k + 1;
            break;
          }
        }
      }
    } else {
      for (int j = 0; j < 3; j++) {
        int cur = d[i][j];
        color[cur] = j + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", color[i]);
}
