#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, i;
  cin >> n >> m;
  map<int, int> mp;
  for (i = 0; i < 3; i++) {
    int t;
    cin >> t;
    if (i == 0) mp[t] = 1;
    if (i == 1) mp[t] = 2;
    if (i == 2) mp[t] = 3;
  }
  for (i = 1; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (mp[a] == 0 && mp[b] == 0 && mp[c] == 0) {
      mp[a] = 1;
      mp[b] = 2;
      mp[c] = 3;
    } else {
      if (mp[a] != 0) {
        int cur = b;
        for (int j = 1; j <= 3; j++) {
          if (mp[a] != j) {
            mp[cur] = j;
            cur = c;
          }
        }
      } else if (mp[b] != 0) {
        int cur = a;
        for (int j = 1; j <= 3; j++) {
          if (mp[b] != j) {
            mp[cur] = j;
            cur = c;
          }
        }
      } else {
        int cur = a;
        for (int j = 1; j <= 3; j++) {
          if (mp[c] != j) {
            mp[cur] = j;
            cur = b;
          }
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    cout << mp[i] << " ";
  }
}
