#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a, b, c;
  int i;
  vector<vector<int> > d(n + 1, vector<int>());
  vector<int> color(n + 1, 0);
  vector<int> parent(n + 1, 0);
  queue<int> seen;
  for (i = 0; i < m; ++i) {
    cin >> a >> b >> c;
    d[a].push_back(b);
    d[a].push_back(c);
    d[b].push_back(a);
    d[b].push_back(c);
    d[c].push_back(a);
    d[c].push_back(b);
  }
  for (int j = 1; j <= n; ++j) {
    if (color[j] == 0) {
      seen.push(j);
      while (!seen.empty()) {
        int val = seen.front();
        seen.pop();
        if (color[val] == 0) {
          if (parent[val] != 1)
            color[val] = 1;
          else if (parent[val] != 2)
            color[val] = 2;
          else if (parent[val] != 3)
            color[val] = 3;
        }
        for (i = 0; i < d[val].size(); ++i) {
          if (parent[d[val][i]] == 0) {
            parent[d[val][i]] = color[val];
            seen.push(d[val][i]);
          } else {
            if (color[val] != parent[d[val][i]]) {
              switch (color[val] * parent[d[val][i]]) {
                case 2:
                  color[d[val][i]] = 3;
                  break;
                case 3:
                  color[d[val][i]] = 2;
                  break;
                case 6:
                  color[d[val][i]] = 1;
                  break;
              }
            }
          }
        }
      }
    }
  }
  for (i = 1; i <= n; ++i) {
    cout << color[i] << " ";
  }
  cout << endl;
  return 0;
}
