#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long z) {
  long long ret = 1;
  while (y > 0) {
    if (y & 1) ret = (ret * x) % z;
    x = (x * x) % z;
    y >>= 1;
  }
  return ret;
}
const long long N = 1e5 + 5, P1 = 32452867, P2 = 49979687, M1 = 1e9 + 7,
                M2 = 1e9 + 9;
vector<long long> V[N];
long long has[N][2], cc = 0, vis[N];
set<pair<long long, long long> > col1;
void dfs(long long x) {
  vis[x] = 1;
  for (auto u : V[x]) {
    if (!vis[u]) dfs(u);
  }
  return;
}
void getHash(long long x) {
  long long p = P1, mod = M1;
  for (auto u : V[x]) {
    has[x][0] = (has[x][0] + (u * p) % mod) % mod;
    p = (p * p) % mod;
  }
  p = P2, mod = M2;
  for (auto u : V[x]) {
    has[x][1] = (has[x][0] + (u * p) % mod) % mod;
    p = (p * p) % mod;
  }
  col1.insert(make_pair(has[x][0], has[x][1]));
  return;
}
int main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  while (m--) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    V[a].push_back(b);
    V[b].push_back(a);
  }
  for (long long i = 1; i <= n; ++i) sort((V[i]).begin(), (V[i]).end());
  for (long long i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i), ++cc;
  if (cc > 1)
    printf("-1\n");
  else {
    for (long long i = 1; i <= n; ++i) getHash(i);
    long long sz = col1.size();
    if (sz != 3)
      printf("-1\n");
    else {
      map<pair<long long, long long>, long long> mk;
      long long cnt = 1;
      for (auto u : col1) mk[u] = cnt++;
      for (long long i = 1; i <= n; ++i)
        printf("%lld ", mk[make_pair(has[i][0], has[i][1])]);
      printf("\n");
    }
  }
  return 0;
}
