#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1, 0);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (!ans[a]) {
      for (int i = 1; i <= 3; i++) {
        if (i != ans[b] and i != ans[c]) {
          ans[a] = i;
        }
      }
    }
    if (!ans[b]) {
      for (int i = 1; i <= 3; i++) {
        if (i != ans[c] and i != ans[a]) {
          ans[b] = i;
        }
      }
    }
    if (!ans[c]) {
      for (int i = 1; i < 3; i++) {
        if (i != ans[b] and i != ans[a]) {
          ans[c] = i;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
