#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int color[100001] = {0};
  for (int i = 0; i <= n; i++) color[i] = 0;
  for (int i = 0; i < m; i++) {
    int c[3];
    for (int j = 0; j < 3; j++) cin >> c[j];
    if (i == 0) {
      for (int j = 0; j < 3; j++) {
        color[c[j]] = j + 1;
      }
      continue;
    }
    bool match[4];
    for (int j = 1; j <= 3; j++) match[j] = false;
    match[0] = true;
    for (int j = 0; j < 3; j++) {
      if (color[c[j]] != 0) continue;
      for (int k = 0; k < 3; k++) {
        if (j != k) {
          match[color[c[k]]] = true;
        }
      }
      for (int k = 0; k < 3; k++)
        if (!match[k + 1]) {
          color[c[j]] = k + 1;
          break;
        }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", color[i]);
  return 0;
}
