#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int n, a[4], ma[N], m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[1] >> a[2] >> a[3];
    if (i == 1) {
      ma[a[1]] = 1;
      ma[a[2]] = 2;
      ma[a[3]] = 3;
    } else {
      if (ma[a[1]] > 0) {
        ma[a[2]] = ma[a[1]] + 1;
        if (ma[a[2]] > 3) ma[a[2]] -= 3;
        ma[a[3]] = ma[a[1]] + 2;
        if (ma[a[3]] > 3) ma[a[3]] -= 3;
      } else {
        if (ma[a[2]] > 0) {
          ma[a[1]] = ma[a[2]] + 1;
          if (ma[a[1]] > 3) ma[a[1]] -= 3;
          ma[a[3]] = ma[a[2]] + 2;
          if (ma[a[3]] > 3) ma[a[3]] -= 3;
        } else {
          if (ma[a[3]] > 0) {
            ma[a[2]] = ma[a[3]] + 1;
            if (ma[a[2]] > 3) ma[a[2]] -= 3;
            ma[a[1]] = ma[a[3]] + 2;
            if (ma[a[1]] > 3) ma[a[1]] -= 3;
          } else {
            ma[a[1]] = 1;
            ma[a[2]] = 2;
            ma[a[3]] = 3;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ma[i] << " ";
  }
}
