#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  vector<vector<int> > AdjList(500000);
  int belong[500000];
  int parts[4] = {0, 0, 0, 0};
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    AdjList[a].push_back(b);
    AdjList[b].push_back(a);
  }
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    if (belong[i] == 0) {
      if (cur >= 3) {
        printf("-1\n");
        return 0;
      }
    } else
      continue;
    ++cur;
    bitset<500000> bs;
    bs.set();
    for (int p : AdjList[i]) bs[p] = 0;
    for (int j = 1; j <= n; j++) {
      if (bs[j]) {
        belong[j] = cur;
        parts[cur]++;
      }
    }
  }
  if (cur != 3) {
    printf("-1\n");
    return 0;
  }
  int edges = parts[1] * parts[2] + parts[2] * parts[3] + parts[3] * parts[1];
  if (edges != m) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int p : AdjList[i]) {
      if (belong[p] == belong[i]) {
        printf("-1\n");
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i != n)
      printf("%d ", belong[i]);
    else
      printf("%d", belong[i]);
  }
}
