#include <bits/stdc++.h>
using namespace std;
int man[100000];
int main() {
  int n, m, a, c, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (man[a]) {
      switch (man[a]) {
        case 1:
          man[b] = 2;
          man[c] = 3;
          break;
        case 2:
          man[b] = 1;
          man[c] = 3;
          break;
        case 3:
          man[b] = 1;
          man[c] = 2;
          break;
      }
    } else if (man[b]) {
      switch (man[b]) {
        case 1:
          man[a] = 2;
          man[c] = 3;
          break;
        case 2:
          man[a] = 1;
          man[c] = 3;
          break;
        case 3:
          man[a] = 1;
          man[c] = 2;
          break;
      }
    } else if (man[c]) {
      switch (man[c]) {
        case 1:
          man[b] = 2;
          man[a] = 3;
          break;
        case 2:
          man[b] = 1;
          man[a] = 3;
          break;
        case 3:
          man[b] = 1;
          man[a] = 2;
          break;
      }
    } else {
      man[a] = 1;
      man[b] = 2;
      man[c] = 3;
    }
  }
  for (int i = 1; i <= n; i++) cout << man[i] << " ";
}
