#include <bits/stdc++.h>
using namespace std;
long ans[100005];
int main() {
  long n, m, i, a, b, c, temp, temp1;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (ans[a]) {
      if (ans[a] == 1)
        ans[b] = 2, ans[c] = 3;
      else if (ans[a] == 2)
        ans[b] = 1, ans[c] = 3;
      else
        ans[b] = 1, ans[c] = 2;
    } else if (ans[b]) {
      if (ans[b] == 1)
        ans[a] = 2, ans[c] = 3;
      else if (ans[b] == 2)
        ans[a] = 1, ans[c] = 3;
      else
        ans[a] = 1, ans[c] = 2;
    } else if (ans[c]) {
      if (ans[c] == 1)
        ans[a] = 2, ans[b] = 3;
      else if (ans[c] == 2)
        ans[a] = 1, ans[b] = 3;
      else
        ans[a] = 1, ans[b] = 2;
    } else
      ans[a] = 1, ans[b] = 2, ans[c] = 3;
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
