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