#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long cnt[3];
long long color[1000005];
set<long long> adj[1000005];
long long solve() {
  cin >> n >> m;
  pair<long long, long long> e[m];
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].insert(v);
    adj[v].insert(u);
    e[i] = (make_pair(u, v));
  }
  for (long long i = 0; i < n; i++) color[i] = -1;
  long long curr = 0;
  for (long long i = 0; i < n; i++) {
    if (color[i] != -1) continue;
    for (long long j = 0; j < n; j++) {
      if (adj[i].count(j) == false) color[j] = curr;
    }
    curr++;
    if (curr == 3) break;
  }
  for (long long i = 0; i < n; i++) {
    if (color[i] == -1) {
      cout << -1;
      return 0;
    }
  }
  for (long long i = 0; i < n; i++) cnt[color[i]]++;
  if (cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0) {
    cout << -1;
    return 0;
  }
  for (long long i = 0; i < m; i++) {
    if (color[e[i].first] == color[e[i].second]) {
      cout << -1;
      return 0;
    }
  }
  if (cnt[0] * cnt[1] + cnt[0] * cnt[2] + cnt[1] * cnt[2] != m) {
    cout << -1;
    return 0;
  }
  for (long long i = 0; i < n; i++) cout << color[i] + 1 << " ";
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long t = 1;
  while (t-- != 0) {
    long long stat = solve();
  }
  return 0;
}
