#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    if (a[x]) {
      a[y] = a[x] % 3 + 1;
      a[z] = a[y] % 3 + 1;
    } else if (a[y]) {
      a[z] = a[y] % 3 + 1;
      a[x] = a[z] % 3 + 1;
    } else if (a[z]) {
      a[x] = a[z] % 3 + 1;
      a[y] = a[x] % 3 + 1;
    } else {
      a[x] = 1;
      a[y] = 2;
      a[z] = 3;
    }
  }
  for (int i = 1; i <= n; i++) cout << a[i] << ' ';
  return 0;
}
