#include <bits/stdc++.h>
using namespace std;
void print1d(vector<long long> &A) {
  for (auto i : A) cout << i << " ";
  cout << endl;
}
void print2d(vector<vector<long long>> &A) {
  for (auto i : A) {
    for (auto j : i) cout << j << " ";
    cout << endl;
  }
}
void printadj(unordered_map<long long, vector<long long>> &mp) {
  for (auto it : mp) {
    cout << it.first << " --> ";
    for (long long i = 0; i < it.second.size(); i++) {
      cout << it.second[i] << " ";
    }
    cout << endl;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  long long a, b, c;
  map<long long, long long> mp;
  for (long long i = 0; i < m; i++) {
    set<long long> s;
    s.insert(1);
    s.insert(2);
    s.insert(3);
    cin >> a >> b >> c;
    if (mp.find(a) != mp.end()) {
      s.erase(mp[a]);
      if (mp[a] == 1) {
        mp[b] = 2;
        mp[c] = 3;
      } else if (mp[a] == 2) {
        mp[b] = 1;
        mp[c] = 3;
      } else if (mp[a] == 3) {
        mp[b] = 1;
        mp[c] = 2;
      }
    } else if (mp.find(b) != mp.end()) {
      s.erase(mp[b]);
      if (mp[b] == 1) {
        mp[a] = 2;
        mp[c] = 3;
      } else if (mp[b] == 2) {
        mp[a] = 1;
        mp[c] = 3;
      } else if (mp[b] == 3) {
        mp[a] = 1;
        mp[c] = 2;
      }
    } else if (mp.find(c) != mp.end()) {
      s.erase(mp[c]);
      if (mp[c] == 1) {
        mp[a] = 2;
        mp[b] = 3;
      } else if (mp[c] == 2) {
        mp[a] = 1;
        mp[b] = 3;
      } else if (mp[c] == 3) {
        mp[a] = 1;
        mp[b] = 2;
      }
    } else {
      mp[a] = 1;
      mp[b] = 2;
      mp[c] = 3;
    }
  }
  for (auto it : mp) {
    cout << it.second << " ";
  }
  return 0;
}
