#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> adj[n];
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u -= 1;
    v -= 1;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  set<long long> f;
  for (long long i = 0; i < n; i++) f.insert(i);
  for (long long i = 0; i < adj[0].size(); i++) f.erase(adj[0][i]);
  set<long long> s;
  for (long long i = 1; i < n; i++) {
    if (f.find(i) == f.end()) {
      long long ele = i;
      for (long long j = 0; j < adj[ele].size(); j++)
        if (f.find(adj[ele][j]) == f.end()) s.insert(adj[ele][j]);
      break;
    }
  }
  set<long long> t;
  for (long long i = 0; i < n; i++)
    if (f.find(i) == f.end() && s.find(i) == s.end()) t.insert(i);
  for (long long i = 0; i < n; i++) {
    long long cnt = (f.find(i) != f.end()) + (s.find(i) != s.end()) +
                    (t.find(i) != t.end());
    if (cnt != 1) {
      cout << "-1";
      return 0;
    }
  }
  if (f.size() == 0 || s.size() == 0 || t.size() == 0) {
    cout << "-1";
    return 0;
  }
  long long color[n];
  for (long long i = 0; i < n; i++) {
    if (f.find(i) != f.end())
      color[i] = 1;
    else if (s.find(i) != s.end())
      color[i] = 2;
    else if (t.find(i) != t.end())
      color[i] = 3;
    else {
      cout << "-1";
      return 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < adj[i].size(); j++) {
      if (color[i] == color[adj[i][j]]) {
        cout << "-1";
        return 0;
      }
    }
  }
  long long cnt =
      f.size() * s.size() + s.size() * t.size() + t.size() * f.size();
  if (cnt != m) {
    cout << "-1";
    return 0;
  }
  for (long long i = 0; i < n; i++) cout << color[i] << " ";
}
