#include <bits/stdc++.h>
using namespace std;
bool sortmahstyle(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first < b.first) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int hash[n + 1], col[4];
  memset(hash, 0, sizeof(hash));
  while (m--) {
    memset(col, 0, sizeof(col));
    long long int inp[3];
    for (long long int i = 0; i < 3; i++) {
      cin >> inp[i];
      col[hash[inp[i]]] = 1;
    }
    for (long long int i = 0; i < 3; i++) {
      long long int x = inp[i];
      if (hash[x] == 0) {
        for (long long int j = 1; j < 4; j++) {
          if (col[j] == 0) {
            hash[x] = j;
            col[hash[x]] = 1;
            break;
          }
        }
      } else {
        col[hash[x]] = 1;
      }
    }
  }
  for (long long int i = 1; i < n + 1; i++) cout << hash[i] << " ";
  return 0;
}
