#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  unsigned long long n, m;
  cin >> n >> m;
  map<long long, set<unsigned long long>> hashed;
  vector<vector<unsigned long long>> graph(n);
  for (unsigned long long i = 0; i < m; ++i) {
    unsigned long long a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  const unsigned long long MOD = 1500000001;
  for (unsigned long long i = 0; i < n; ++i) {
    long long hasher = 0;
    for (unsigned long long v : graph[i]) {
      hasher += (v * (v * v) % MOD + 4 * v) % MOD;
      hasher %= MOD;
    }
    hashed[hasher].insert(i);
  }
  if (hashed.size() != 3) {
    cout << -1;
  } else {
    vector<unsigned long long> answer(n, 0);
    unsigned long long i = 1;
    for (auto &pa : hashed) {
      if (pa.first == 0LL) {
        cout << -1;
        return 0;
      }
      for (unsigned long long x : pa.second) {
        answer[x] = i;
      }
      i++;
    }
    for (unsigned long long x : answer) {
      cout << x << ' ';
    }
    cout << '\n';
  }
}
