#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> m >> n;
  map<int, int> mp;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (mp[a[i]] == 0 && mp[b[i]] == 0 && mp[c[i]] == 0) {
      mp[a[i]] = 1;
      mp[b[i]] = 2;
      mp[c[i]] = 3;
    } else if (mp[b[i]] == 0 && mp[c[i]] == 0) {
      k = mp[a[i]];
      if (k == 1) {
        mp[b[i]] = 2;
        mp[c[i]] = 3;
      } else if (k == 2) {
        mp[b[i]] = 1;
        mp[c[i]] = 3;
      } else {
        mp[b[i]] = 1;
        mp[c[i]] = 2;
      }
    } else if (mp[a[i]] == 0 && mp[c[i]] == 0) {
      k = mp[b[i]];
      if (k == 1) {
        mp[a[i]] = 2;
        mp[c[i]] = 3;
      } else if (k == 2) {
        mp[a[i]] = 1;
        mp[c[i]] = 3;
      } else {
        mp[a[i]] = 1;
        mp[c[i]] = 2;
      }
    } else if (mp[a[i]] == 0 && mp[b[i]] == 0) {
      k = mp[c[i]];
      if (k == 1) {
        mp[b[i]] = 2;
        mp[a[i]] = 3;
      } else if (k == 2) {
        mp[b[i]] = 1;
        mp[a[i]] = 3;
      } else {
        mp[b[i]] = 1;
        mp[a[i]] = 2;
      }
    } else {
      continue;
    }
  }
  for (auto it : mp) {
    cout << it.second << " ";
  }
}
