#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int main() {
  int n, m, x, y, z;
  cin >> n >> m;
  while (m--) {
    cin >> x >> y >> z;
    if (arr[x]) {
      if (arr[x] == 1) {
        arr[y] = 2;
        arr[z] = 3;
      } else if (arr[x] == 2) {
        arr[y] = 1;
        arr[z] = 3;
      } else {
        arr[y] = 1;
        arr[z] = 2;
      }
    } else if (arr[y]) {
      if (arr[y] == 1) {
        arr[x] = 2;
        arr[z] = 3;
      } else if (arr[y] == 2) {
        arr[x] = 1;
        arr[z] = 3;
      } else {
        arr[x] = 1;
        arr[z] = 2;
      }
    } else if (arr[z]) {
      if (arr[z] == 1) {
        arr[x] = 2;
        arr[y] = 3;
      } else if (arr[z] == 2) {
        arr[x] = 1;
        arr[y] = 3;
      } else {
        arr[x] = 1;
        arr[y] = 2;
      }
    } else {
      arr[x] = 1;
      arr[y] = 2;
      arr[z] = 3;
    }
  }
  for (int i = 1; i <= n; i++) cout << arr[i] << " ";
  cout << endl;
  return 0;
}
