#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
string toString(long long n) {
  stringstream second;
  second << n;
  return second.str();
}
long long toNumber(string s) {
  stringstream second;
  long long n;
  second << s;
  second >> n;
  return n;
}
map<int, int> mapi;
int n, m, a, b, c;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (mapi[a] > 0) {
      mapi[b] = 1 ^ mapi[a];
      if (mapi[b] == 0) mapi[b] = 2;
      mapi[c] = mapi[a] ^ mapi[b];
    } else if (mapi[b] > 0) {
      mapi[c] = 1 ^ mapi[b];
      if (mapi[c] == 0) mapi[c] = 2;
      mapi[a] = mapi[b] ^ mapi[c];
    } else if (mapi[c] > 0) {
      mapi[a] = 1 ^ mapi[c];
      if (mapi[a] == 0) mapi[a] = 2;
      mapi[b] = mapi[a] ^ mapi[c];
    } else {
      mapi[a] = 1;
      mapi[b] = 2;
      mapi[c] = 3;
    }
  }
  for (int i = 1; i < n + 1; i++) {
    cout << mapi[i] << " ";
  }
  cout << '\n';
  return 0;
}
