#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<set<int>> edge(n + 1);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    edge[u].insert(v);
    edge[v].insert(u);
  }
  vector<int> ans(n + 1);
  for (int type = 1; type <= 3; ++type) {
    int i;
    for (i = 1; i <= n; ++i)
      if (!ans[i]) break;
    if (i == n + 1) return cout << "-1", 0;
    ans[i] = type;
    for (int id = 1; id <= n; ++id) {
      if (!ans[id] && id != i && edge[i].find(id) == edge[i].end())
        ans[id] = type;
    }
  }
  vector<vector<int>> vt(3);
  for (int i = 1; i <= n; ++i) {
    if (!ans[i]) return cout << "-1", 0;
    vt[ans[i] - 1].emplace_back(i);
  }
  int counter = 0;
  auto check = [&](const vector<int>& a, const vector<int>& b) {
    for (auto& x : a)
      for (auto& y : b)
        if (edge[x].find(y) == edge[x].end()) {
          cout << "-1";
          exit(0);
        } else
          counter++;
  };
  check(vt[0], vt[1]);
  check(vt[2], vt[1]);
  check(vt[0], vt[2]);
  if (counter != m)
    cout << "-1";
  else
    for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
}
