#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> colors(n + 1, -1);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> temp{a, b, c};
    sort(temp.begin(), temp.end());
    int j = -1;
    for (int i = 0; i < 3; ++i) {
      if (i == j) continue;
      if (colors[temp[i]] != -1) {
        colors[temp[colors[temp[i]]]] = i;
        j = colors[temp[i]];
      } else
        colors[temp[i]] = i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (colors[i] == -1)
      cout << 1 << " ";
    else
      cout << colors[i] + 1 << " ";
  }
  cout << "\n";
}
