#include <bits/stdc++.h>
using namespace std;
vector<long long int> lst[100005];
struct edge {
  long long int u, v;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int u, v, n, m, i, j, sz[4] = {0}, to;
  cin >> n >> m;
  vector<edge> e(m);
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    lst[u].push_back(v);
    lst[v].push_back(u);
    e[i].u = u;
    e[i].v = v;
  }
  vector<long long int> hs(n + 1, 1);
  for (i = 1; i <= n; i++) {
    if (hs[i] == 1) {
      for (j = 0; j < lst[i].size(); j++) {
        to = lst[i][j];
        hs[to] = 2;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (hs[i] != 1 && hs[i] != 3) {
      for (j = 0; j < lst[i].size(); j++) {
        to = lst[i][j];
        if (hs[to] == 2) hs[to] = 3;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    sz[hs[i]]++;
  }
  if (m != sz[1] * sz[2] + sz[2] * sz[3] + sz[3] * sz[1])
    cout << -1 << "\n";
  else if (sz[1] == 0 || sz[2] == 0 || sz[3] == 0)
    cout << -1 << "\n";
  else {
    for (i = 0; i < m; i++) {
      u = e[i].u;
      v = e[i].v;
      if (hs[u] == hs[v]) {
        cout << -1 << "\n";
        return 0;
      }
    }
    for (i = 1; i <= n; i++) cout << hs[i] << " ";
    cout << "\n";
  }
  return 0;
}
