#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  map<int, int> ma;
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    if (ma[a]) {
      if (ma[b]) {
        if ((ma[a] == 1 && ma[b] == 2) || (ma[a] == 2 && ma[b] == 1))
          ma[c] = 3;
        else if ((ma[a] == 1 && ma[b] == 3) || (ma[a] == 2 && ma[b] == 1))
          ma[c] = 2;
        else
          ma[c] = 1;
      } else if (ma[c]) {
        if ((ma[a] == 1 && ma[c] == 2) || (ma[a] == 2 && ma[c] == 1))
          ma[b] = 3;
        else if ((ma[a] == 1 && ma[c] == 3) || (ma[a] == 2 && ma[c] == 1))
          ma[b] = 2;
        else
          ma[b] = 1;
      } else if (ma[a] == 1)
        ma[b] = 2, ma[c] = 3;
      else if (ma[a] == 2)
        ma[b] = 1, ma[c] = 3;
      else
        ma[b] = 2, ma[c] = 1;
    } else if (ma[b]) {
      swap(a, b);
      if (ma[b]) {
        if ((ma[a] == 1 && ma[b] == 2) || (ma[a] == 2 && ma[b] == 1))
          ma[c] = 3;
        else if ((ma[a] == 1 && ma[b] == 3) || (ma[a] == 2 && ma[b] == 1))
          ma[c] = 2;
        else
          ma[c] = 1;
      } else if (ma[c]) {
        if ((ma[a] == 1 && ma[c] == 2) || (ma[a] == 2 && ma[c] == 1))
          ma[b] = 3;
        else if ((ma[a] == 1 && ma[c] == 3) || (ma[a] == 2 && ma[c] == 1))
          ma[b] = 2;
        else
          ma[b] = 1;
      } else if (ma[a] == 1)
        ma[b] = 2, ma[c] = 3;
      else if (ma[a] == 2)
        ma[b] = 1, ma[c] = 3;
      else
        ma[b] = 2, ma[c] = 1;
    } else {
      swap(a, c);
      if (ma[b]) {
        if ((ma[a] == 1 && ma[b] == 2) || (ma[a] == 2 && ma[b] == 1))
          ma[c] = 3;
        else if ((ma[a] == 1 && ma[b] == 3) || (ma[a] == 2 && ma[b] == 1))
          ma[c] = 2;
        else
          ma[c] = 1;
      } else if (ma[c]) {
        if ((ma[a] == 1 && ma[c] == 2) || (ma[a] == 2 && ma[c] == 1))
          ma[b] = 3;
        else if ((ma[a] == 1 && ma[c] == 3) || (ma[a] == 2 && ma[c] == 1))
          ma[b] = 2;
        else
          ma[b] = 1;
      } else if (ma[a] == 1)
        ma[b] = 2, ma[c] = 3;
      else if (ma[a] == 2)
        ma[b] = 1, ma[c] = 3;
      else
        ma[b] = 2, ma[c] = 1;
      if (!ma[a]) {
        ma[a] = 3;
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << max(ma[i], 1) << ' ';
}
