#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V>& x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T& x) {
  int f = 0;
  cerr << '{';
  for (auto& i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  int u, v;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  map<vector<int>, int> mp;
  map<vector<int>, vector<int>> inds;
  for (int i = 0; i < n; ++i) {
    sort(adj[i].begin(), adj[i].end());
    mp[adj[i]]++;
    inds[adj[i]].push_back(i);
  }
  bool f = true;
  vector<int> ans(n);
  int cnt = 1;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    auto v = it->first;
    int val = it->second;
    if (n - val != v.size()) {
      f = false;
      break;
    }
    for (int i : inds[v]) {
      ans[i] = cnt;
    }
    ++cnt;
  }
  if (f && mp.size() == 3) {
    for (int i : ans) {
      cout << i << " ";
    }
    cout << "\n";
  } else {
    cout << -1 << "\n";
  }
  return 0;
}
