#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007, ar = 100005;
int res[ar];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x, y;
  cin >> x >> y;
  memset(res, -1, sizeof res);
  for (int w = 0; w < y; w++) {
    int a, b, c, x = 0, y = 0, z = 0;
    cin >> a >> b >> c;
    if (res[a] != -1 && res[b] != -1 && res[c] == -1) {
      res[c] = 6 - (res[a] + res[b]);
    }
    if (res[a] != -1 && res[c] != -1 && res[b] == -1) {
      res[b] = 6 - (res[a] + res[c]);
    }
    if (res[a] == -1 && res[b] != -1 && res[c] != -1) {
      res[a] = 6 - (res[c] + res[b]);
    }
    if (res[a] == -1 && res[b] == -1 && res[c] == -1) {
      res[a] = 1;
      res[b] = 2;
      res[c] = 3;
    }
    if (res[a] == -1 && res[b] == -1 && res[c] != -1) {
      if (res[c] % 2)
        res[b] = 2, res[a] = 6 - (res[b] + res[c]);
      else
        res[a] = 1, res[b] = 3;
    }
    if (res[a] == -1 && res[c] == -1 && res[b] != -1) {
      if (res[b] % 2)
        res[a] = 2, res[c] = 6 - (res[b] + res[a]);
      else
        res[a] = 1, res[c] = 3;
    }
    if (res[b] == -1 && res[c] == -1 && res[a] != -1) {
      if (res[a] % 2)
        res[b] = 2, res[c] = 6 - (res[b] + res[a]);
      else
        res[b] = 1, res[c] = 3;
    }
  }
  for (int w = 1; w <= x; w++) {
    cout << res[w] << " ";
  }
  return 0;
}
