#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998242353, mod2 = 1e9 + 9,
          inf = 1e9 + 7;
const long long infll = 1e18 + 7;
int n, m;
set<int> adj[N];
int par[N];
int col[N];
bool ck[N];
vector<int> col1, col2, col3;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(par, -1, sizeof(par));
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].insert(y);
    adj[y].insert(x);
  }
  for (auto v = adj[1].begin(); v != adj[1].end(); v++) {
    ck[*v] = 1;
  }
  col[1] = 1;
  col1.push_back(1);
  for (int i = 1; i <= n; i++) {
    if (!ck[i]) {
      col[i] = 1;
      col1.push_back(i);
    }
  }
  int idx = 0;
  for (int i = 1; i <= n; i++) {
    if (col[i] == 0) {
      idx = i;
      break;
    }
  }
  memset(ck, 0, sizeof(ck));
  for (auto v = adj[idx].begin(); v != adj[idx].end(); v++) {
    if (col[*v] == 0) {
      ck[*v] = 1;
    }
  }
  col[idx] = 2;
  col2.push_back(idx);
  for (int i = 1; i <= n; i++) {
    if (!ck[i] && col[i] == 0) {
      col[i] = 2;
      col2.push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (col[i] == 0) {
      col[i] = 3;
      col3.push_back(i);
    }
  }
  if (col3.size() == 0) return cout << -1, 0;
  ;
  for (int i = 1; i <= n; i++) {
    for (auto v = adj[i].begin(); v != adj[i].end(); v++) {
      if (col[i] == col[*v]) return cout << -1, 0;
      ;
    }
  }
  for (auto u : col1) {
    for (auto v : col2) {
      if (adj[u].find(v) == adj[u].end()) return cout << -1, 0;
      ;
      if (adj[v].find(u) == adj[v].end()) return cout << -1, 0;
      ;
    }
  }
  for (auto u : col2) {
    for (auto v : col3) {
      if (adj[u].find(v) == adj[u].end()) return cout << -1, 0;
      ;
      if (adj[v].find(u) == adj[v].end()) return cout << -1, 0;
      ;
    }
  }
  for (auto u : col3) {
    for (auto v : col1) {
      if (adj[u].find(v) == adj[u].end()) return cout << -1, 0;
      ;
      if (adj[v].find(u) == adj[v].end()) return cout << -1, 0;
      ;
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << col[i] << ' ';
  }
}
