#include <bits/stdc++.h>
using namespace std;
void solve(vector<vector<int>> a, int n, int m, vector<int>& ans) {
  for (int i = 0; i < m; i++) {
    vector<bool> color(3, true);
    if (ans[a[i][0] - 1] != -1) color[ans[a[i][0] - 1] - 1] = false;
    if (ans[a[i][1] - 1] != -1) color[ans[a[i][1] - 1] - 1] = false;
    if (ans[a[i][2] - 1] != -1) color[ans[a[i][2] - 1] - 1] = false;
    if (ans[a[i][0] - 1] == -1) {
      for (int j = 0; j < 3; j++) {
        if (color[j]) {
          ans[a[i][0] - 1] = j + 1;
          color[j] = false;
          break;
        }
      }
    }
    if (ans[a[i][1] - 1] == -1) {
      for (int j = 0; j < 3; j++) {
        if (color[j]) {
          ans[a[i][1] - 1] = j + 1;
          color[j] = false;
          break;
        }
      }
    }
    if (ans[a[i][2] - 1] == -1) {
      for (int j = 0; j < 3; j++) {
        if (color[j]) {
          ans[a[i][2] - 1] = j + 1;
          color[j] = false;
          break;
        }
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(m, vector<int>(3));
  for (int i = 0; i < m; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
  vector<int> ans(n, -1);
  solve(a, n, m, ans);
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
