#include <bits/stdc++.h>
using namespace std;
string FILENAME = "filename";
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  unordered_map<int, int> color;
  for (int i = 1; i <= n; i++) color[i] = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (color[a] or color[b] or color[c]) {
      set<int> st = {1, 2, 3};
      st.erase(color[a]);
      st.erase(color[b]);
      st.erase(color[c]);
      if (color[a]) {
        color[b] = *st.begin();
        color[c] = *(++st.begin());
      } else if (color[b]) {
        color[a] = *st.begin();
        color[c] = *(++st.begin());
      } else {
        color[b] = *st.begin();
        color[a] = *(++st.begin());
      }
    } else {
      color[a] = 1;
      color[b] = 2;
      color[c] = 3;
    }
  }
  for (int i = 1; i <= n; i++) cout << color[i] << endl;
}
