#include <bits/stdc++.h>
using namespace std;
int n, a[200000] = {0}, m, x, y, z;
int main() {
  cin >> n >> m;
  cin >> x >> y >> z;
  a[x] = 1;
  a[y] = 2;
  a[z] = 3;
  for (int i = (2), _b = (m); i <= _b; i++) {
    cin >> x >> y >> z;
    if (a[x] != 0) {
      for (int j = (1), _b = (3); j <= _b; j++)
        if (j != a[x]) {
          a[y] = j;
          break;
        }
      a[z] = 6 - a[y] - a[x];
    } else {
      if (a[y] != 0) {
        for (int j = (1), _b = (3); j <= _b; j++)
          if (j != a[y]) {
            a[x] = j;
            break;
          }
        a[z] = 6 - a[y] - a[x];
      } else {
        if (a[z] != 0) {
          for (int j = (1), _b = (3); j <= _b; j++)
            if (j != a[z]) {
              a[x] = j;
              break;
            }
          a[y] = 6 - a[z] - a[x];
        } else {
          a[x] = 1;
          a[y] = 2;
          a[z] = 3;
        }
      }
    }
  }
  for (int i = (1), _b = (n); i <= _b; i++)
    if (a[i] != 0)
      cout << a[i] << " ";
    else
      cout << 1 << " ";
  return 0;
}
