#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int N, M;
int color[100001];
vector<int> adj[100001];
void dfs(int node) {
  for (int x : adj[node]) {
    if (color[x] == 4) {
      if (color[node] == 2)
        color[x] = 3;
      else
        color[x] = 2;
      dfs(node);
    }
  }
}
vector<int> c[4];
map<pair<int, int>, bool> edge;
void fail() {
  cout << -1 << endl;
  exit(0);
}
void check() {
  long long edges = 0;
  for (int i = 1; i <= 3; i++)
    for (int j = i + 1; j <= 3; j++)
      edges += ((long long)(c[i].size())) * ((long long)(c[j].size()));
  if (edges != M) fail();
  for (int i = 1; i <= 3; i++)
    if (c[i].size() == 0) fail();
  for (int i = 1; i <= 3; i++) {
    for (int j = i + 1; j <= 3; j++) {
      for (int x : c[i])
        for (int y : c[j])
          if (!edge[{x, y}]) fail();
    }
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) {
    int X, Y;
    scanf("%d%d", &X, &Y);
    edge[{X, Y}] = true;
    edge[{Y, X}] = true;
    adj[X].push_back(Y);
    adj[Y].push_back(X);
  }
  color[1] = 1;
  for (int x : adj[1]) color[x] = 4;
  for (int i = 1; i <= N; i++)
    if (color[i] == 0) color[i] = 1;
  for (int x : adj[1])
    if (color[x] == 4) {
      color[x] = 2;
      dfs(x);
    }
  for (int i = 1; i <= N; i++) c[color[i]].push_back(i);
  check();
  for (int i = 1; i <= N; i++) cout << color[i] << ' ';
  cout << endl;
  return 0;
}
