#include <bits/stdc++.h>
using namespace std;
const int maxn = 100002;
int s[3];
int ans[maxn];
int main() {
  int i, j, k;
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(ans, -1, sizeof(ans));
    int l = 0;
    for (i = 0; i < m; i++) {
      k = 1;
      for (j = 0; j < 3; j++) {
        cin >> s[j];
        if (ans[s[j]] != -1) {
          l = ans[s[j]];
        }
      }
      for (j = 0; j < 3; j++)
        if (ans[s[j]] != l) {
          ans[s[j]] = (l + k) % 3;
          k++;
        }
    }
    for (i = 1; i <= n; i++) printf("%d ", ans[i] + 1);
    printf("\n");
  }
  return 0;
}
