#include <bits/stdc++.h>
using namespace std;
int n, m, ans[100010];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    if (ans[a] == 1)
      ans[b] = 2, ans[c] = 3;
    else if (ans[a] == 2)
      ans[b] = 3, ans[c] = 1;
    else if (ans[a] == 3)
      ans[b] = 1, ans[c] = 2;
    else if (ans[b] == 1)
      ans[c] = 2, ans[a] = 3;
    else if (ans[b] == 2)
      ans[c] = 3, ans[a] = 1;
    else if (ans[b] == 3)
      ans[c] = 1, ans[a] = 2;
    else if (ans[c] == 1)
      ans[a] = 2, ans[b] = 3;
    else if (ans[c] == 2)
      ans[a] = 3, ans[b] = 1;
    else if (ans[c] == 3)
      ans[a] = 1, ans[b] = 2;
    else
      ans[a] = 1, ans[b] = 2, ans[c] = 3;
  }
  for (int i = 0; i < (n); i++) cout << (ans[i] == -1 ? 1 : ans[i]) << " ";
}
