#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, color[100001] = {0};
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (color[a] == color[b] && color[b] == color[c]) {
      color[a] = 1;
      color[b] = 2;
      color[c] = 3;
    } else if (color[a] != 0) {
      int temp = color[a] + 1;
      color[b] = max(1, temp % 4);
      temp = color[b] + 1;
      color[c] = max(1, (temp % 4));
    } else if (color[b] != 0) {
      int temp = color[b] + 1;
      color[a] = max(1, (temp % 4));
      temp = color[a] + 1;
      color[c] = max(1, temp % 4);
    } else if (color[c] != 0) {
      int temp = color[c] + 1;
      color[a] = max(1, temp % 4);
      temp = color[a] + 1;
      color[b] = max(1, temp % 4);
    }
  }
  for (int i = 1; i <= n; i++) cout << color[i] << " ";
}
