#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long power(long long x, long long y, long long m) {
  long long temp;
  if (y == 0) return 1;
  temp = (power(x, y / 2, m)) % m;
  if (y % 2 == 0)
    return ((temp % m) * temp);
  else
    return ((x * temp % m) * temp % m) % m;
}
long long inv(long long x) {
  return (power(x, 998244353 - 2, 998244353)) % 998244353;
}
bool comp(long long a, long long b) { return a > b; }
long long parity[100001], q = 0, freq[3];
vector<vector<long long>> edges(300001);
vector<set<long long>> edgeslook(300001);
void QFS(long long v) {
  parity[v] = 0;
  for (long long i = 0; i < edges[v].size(); i++) {
    if (!i) {
      parity[edges[v][i]] = 1;
      q = edges[v][i];
    } else {
      if (edgeslook[q].find(edges[v][i]) != edgeslook[q].end())
        parity[edges[v][i]] = 2;
      else
        parity[edges[v][i]] = 1;
    }
  }
  for (long long i = 0; i < edges[q].size(); i++) {
    if (edges[q][i] == v) continue;
    if (edgeslook[v].find(edges[q][i]) == edgeslook[v].end())
      parity[edges[q][i]] = 0;
  }
}
int32_t main() {
  iostream::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a, b;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    edges[a - 1].push_back(b - 1), edges[b - 1].push_back(a - 1);
    edgeslook[a - 1].insert(b - 1), edgeslook[b - 1].insert(a - 1);
  }
  for (long long i = 0; i < n; i++) parity[i] = -1;
  QFS(0);
  vector<long long> answer;
  for (long long i = 0; i < n; i++) {
    if (parity[i] == -1) return cout << -1, 0;
    freq[parity[i]]++;
  }
  if (!(freq[0] && freq[1] && freq[2])) return cout << -1, 0;
  for (long long i = 0; i < n; i++) {
    for (long long l = 0; l < edges[i].size(); l++) {
      if (parity[edges[i][l]] == parity[i]) return cout << -1, 0;
    }
    if (edges[i].size() != (freq[0] + freq[1] + freq[2] - freq[parity[i]]))
      return cout << -1, 0;
  }
  for (long long i = 0; i < n; i++) cout << parity[i] + 1 << ' ';
  return 0;
}
