#include <bits/stdc++.h>
using namespace std;
long long int n, m, i, label[100001], a, b, j;
vector<long long int> adj[100001], l[3];
vector<pair<long long int, long long int> > edges;
int main() {
  scanf("%lld%lld", &n, &m);
  for (i = 1; i <= n; i++) {
    label[i] = 1;
    adj[i].clear();
  }
  edges.clear();
  l[0].clear();
  l[1].clear();
  l[2].clear();
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld", &a, &b);
    edges.push_back(make_pair(a, b));
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    if (adj[i].empty()) {
      printf("-1\n");
      return 0;
    }
  }
  for (j = 0; j < adj[1].size(); j++) {
    label[adj[1][j]] = 2;
  }
  a = adj[1][0];
  for (j = 0; j < adj[a].size(); j++) {
    if (label[adj[a][j]] == 2) label[adj[a][j]] = 3;
  }
  for (i = 1; i <= n; i++) {
    l[label[i] - 1].push_back(i);
  }
  if (m != l[0].size() * l[1].size() + l[0].size() * l[2].size() +
               l[1].size() * l[2].size() ||
      l[2].size() == 0) {
    printf("-1\n");
    return 0;
  }
  for (j = 0; j < edges.size(); j++) {
    if (label[edges[j].first] == label[edges[j].second]) {
      printf("-1\n");
      return 0;
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%lld ", label[i]);
  }
  printf("\n");
  return 0;
}
