#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;
struct quad {
  int x, y, z;
};
int color(int x, int y) {
  map<int, bool> has;
  has[x] = true;
  has[y] = true;
  for (int i = 1; i <= 3; i++) {
    if (!has[i]) {
      return i;
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  for (int t = 1; t <= T; t++) {
    int n, m;
    cin >> n >> m;
    vector<quad> nums;
    for (int i = 0; i < m; i++) {
      int x, y, z;
      cin >> x >> y >> z;
      nums.push_back({x, y, z});
    }
    map<int, int> number;
    for (int i = 0; i < m; i++) {
      if (number[nums[i].x] == 0) {
        number[nums[i].x] = color(number[nums[i].y], number[nums[i].z]);
      }
      if (number[nums[i].y] == 0) {
        number[nums[i].y] = color(number[nums[i].x], number[nums[i].z]);
      }
      if (number[nums[i].z] == 0) {
        number[nums[i].z] = color(number[nums[i].x], number[nums[i].y]);
      }
    }
    for (int i = 1; i <= n; i++) {
      cout << number[i] << " ";
    }
  }
}
