#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y, z, d[111111];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    d[i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    cin >> x >> y >> z;
    bool used[4];
    used[1] = false;
    used[2] = false;
    used[3] = false;
    if (d[x] != 0) used[d[x]] = true;
    if (d[y] != 0) used[d[y]] = true;
    if (d[z] != 0) used[d[z]] = true;
    if (d[x] == 0)
      for (int j = 1; j <= 3; j++)
        if (!used[j]) {
          used[j] = true;
          d[x] = j;
          break;
        }
    if (d[y] == 0)
      for (int j = 1; j <= 3; j++)
        if (!used[j]) {
          used[j] = true;
          d[y] = j;
          break;
        }
    if (d[z] == 0)
      for (int j = 1; j <= 3; j++)
        if (!used[j]) {
          used[j] = true;
          d[z] = j;
          break;
        }
  }
  for (int i = 1; i <= n; i++) cout << d[i] << " ";
  return 0;
}
