#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void no() {
  cout << -1 << endl;
  exit(0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  if (m == 0) no();
  vector<set<int>> g(n);
  vector<int> s;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    g[v].insert(u);
    g[u].insert(v);
    if (i == 0) {
      s.push_back(v);
      s.push_back(u);
    }
  }
  for (auto u : g[s[0]]) {
    if (u == s[1]) continue;
    if (g[s[1]].find(u) != g[s[1]].end()) {
      s.push_back(u);
      break;
    }
  }
  if (int((s).size()) == 2) no();
  vector<int> color(n);
  for (int v = 0; v < n; v++) {
    int c = 0;
    for (int i = 1; i < 3; i++) {
      if (g[v].find(s[i]) == g[v].end()) c = i;
    }
    color[v] = c;
  }
  for (int v = 0; v < n; v++) {
    for (auto u : g[v]) {
      if (color[v] == color[u]) no();
    }
  }
  vector<vector<int>> groups(3);
  for (int v = 0; v < n; v++) groups[color[v]].push_back(v);
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 3; j++) {
      for (auto v : groups[i]) {
        for (auto u : groups[j]) {
          if (g[v].find(u) == g[v].end()) no();
        }
      }
    }
  }
  for (auto c : color) cout << (c + 1) << ' ';
  cout << endl;
}
