#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 100, OO = 1e12, M = 1e9 + 7, M2 = 998244353,
                sq = 31622, lg = 23;
set<long long> v[N];
long long mark[N];
void dfs(long long x, long long y) {
  for (auto u : v[x]) {
    if (mark[u]) continue;
    if (v[u].find(y) != v[u].end()) {
      if (mark[y] == 1 && mark[x] == 2) mark[u] = 3;
      if (mark[y] == 1 && mark[x] == 3) mark[u] = 2;
      if (mark[y] == 2 && mark[x] == 3) mark[u] = 1;
      if (mark[y] == 2 && mark[x] == 1) mark[u] = 3;
      if (mark[y] == 3 && mark[x] == 1) mark[u] = 2;
      if (mark[y] == 3 && mark[x] == 2) mark[u] = 1;
      dfs(u, x);
    } else {
      mark[u] = mark[y];
      dfs(u, x);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].insert(y);
    v[y].insert(x);
  }
  mark[0] = 1;
  for (long long i = 1; i <= n; i++) {
    if (!mark[i]) {
      mark[i] = 2;
      dfs(i, 0);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (auto u : v[i]) {
      if (mark[i] == mark[u]) return cout << -1, 0;
    }
  }
  long long t1 = 0, t2 = 0, t3 = 0;
  for (long long i = 1; i <= n; i++) {
    if (mark[i] == 1) t1++;
    if (mark[i] == 2) t2++;
    if (mark[i] == 3) t3++;
  }
  if (!t1 || !t2 || !t3) return cout << -1, 0;
  for (long long i = 1; i <= n; i++) {
    if (mark[i] == 1) {
      if (v[i].size() != t2 + t3) return cout << -1, 0;
    }
    if (mark[i] == 2) {
      if (v[i].size() != t1 + t3) return cout << -1, 0;
    }
    if (mark[i] == 3) {
      if (v[i].size() != t2 + t1) return cout << -1, 0;
    }
  }
  for (long long i = 1; i <= n; i++) cout << mark[i] << " ";
  return 0;
}
