#include <bits/stdc++.h>
using namespace std;
vector<int> remove_duplicate_elements(vector<int> v) {
  vector<int>::iterator ip;
  ip = unique(v.begin(), v.end());
  v.resize(std::distance(v.begin(), ip));
  return v;
}
string make_unique_string(string s) {
  string s1 = "";
  for (int i = 0; i < s.length(); i++) {
    bool flag = true;
    for (int j = 0; j < s1.length(); j++) {
      if (s1[j] == s[i]) {
        flag = false;
        break;
      }
    }
    if (flag) s1 = s1 + s[i];
  }
  return s1;
}
struct vec_thre {
  int first, second, third;
};
bool comp(vec_thre a, vec_thre b) {
  if (a.first != b.first) return a.first < b.first;
  if (a.second != b.second) return a.second < b.second;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first != b.first) return (a.first > b.first);
  return (a.second > b.second);
}
void first_shop(long long a, long long b, long long c) {
  if (a >= c) {
    cout << "-1";
    return;
  }
  cout << 1;
}
void second_shop(long long a, long long b, long long c) {
  long long ctd = b * a;
  if (ctd <= c) {
    cout << "-1";
    return;
  } else {
    cout << b;
  }
}
void solve() {
  long long n, ans = 0, cnt = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      cnt++;
    } else {
      cnt--;
    }
    if (abs(cnt) > abs(ans)) ans = cnt;
  }
  cout << abs(ans) << "\n";
}
long long Minimum(long long n, long long k) {
  long long playerInOneTeam = n / k;
  if (n % k) {
    long long i = n % k;
    long long vaForlarger = playerInOneTeam + 1;
    long long ansForlarger = ((vaForlarger * (vaForlarger - 1)) / 2) * i;
    long long ans =
        ansForlarger + (k - i) * (playerInOneTeam * (playerInOneTeam - 1)) / 2;
    return ans;
  } else {
    long long ans = (playerInOneTeam * (playerInOneTeam - 1) / 2) * k;
    return ans;
  }
}
long long Maximum(long long n, long long k) {
  long long ans = (n - k) * (n - k + 1) / 2;
  return ans;
}
vector<int> adj[500005];
vector<int> visited(500005, 0);
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1, 0), ans(n + 1, 0);
  int danc[m][3];
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    danc[i][0] = a, danc[i][1] = b, danc[i][2] = c;
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    a = danc[i][0];
    b = danc[i][1];
    c = danc[i][2];
    int pre = 0;
    if (ans[a] != 0) {
      pre = ans[a];
      if (pre == 1) {
        ans[b] = 2;
        ans[c] = 3;
      } else if (pre == 2) {
        ans[b] = 1;
        ans[c] = 3;
      } else {
        ans[b] = 1;
        ans[c] = 2;
      }
    } else if (ans[b] != 0) {
      pre = ans[b];
      if (pre == 1) {
        ans[a] = 2;
        ans[c] = 3;
      } else if (pre == 2) {
        ans[a] = 1;
        ans[c] = 3;
      } else {
        ans[a] = 1;
        ans[c] = 2;
      }
    } else if (ans[c] != 0) {
      pre = ans[c];
      if (pre == 1) {
        ans[b] = 2;
        ans[a] = 3;
      } else if (pre == 2) {
        ans[b] = 1;
        ans[a] = 3;
      } else {
        ans[b] = 1;
        ans[a] = 2;
      }
    } else {
      ans[a] = 1;
      ans[b] = 2;
      ans[c] = 3;
    }
  }
  for (int i = 1; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
