#include <bits/stdc++.h>
const int nax = 1e5 + 5;
using namespace std;
int arr[nax];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, t;
  cin >> n >> t;
  int a, b, c;
  for (int i = 0; i < t; i++) {
    cin >> a >> b >> c;
    if (arr[a] == 0 && arr[b] == 0 && arr[c] == 0) {
      arr[a] = 1, arr[b] = 2, arr[c] = 3;
    } else if (arr[a] != 0) {
      arr[b] = ((arr[a] + 1) % 3 == 0 ? (arr[a] + 1) : (arr[a] + 1) % 3);
      arr[c] = ((arr[a] + 2) % 3 == 0 ? (arr[a] + 2) : (arr[a] + 2) % 3);
    } else if (arr[b] != 0) {
      arr[a] = ((arr[b] + 1) % 3 == 0 ? (arr[b] + 1) : (arr[b] + 1) % 3);
      arr[c] = ((arr[b] + 2) % 3 == 0 ? (arr[b] + 2) : (arr[b] + 2) % 3);
    } else if (arr[c] != 0) {
      arr[a] = ((arr[c] + 1) % 3 == 0 ? (arr[c] + 1) : (arr[c] + 1) % 3);
      arr[b] = ((arr[c] + 2) % 3 == 0 ? (arr[c] + 2) : (arr[c] + 2) % 3);
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", arr[i]);
  return 0;
}
