#include <bits/stdc++.h>
using namespace std;
template <typename T>
void _dbg(const char* _s, T _h) {
  cerr << _s << " = " << _h << "\n";
}
template <typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
  int _b = 0;
  while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',') cerr << *_s++;
  cerr << " = " << _h << ",";
  _dbg(_s + 1, _t...);
}
const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int cur = 1;
  vector<int> id(n, 0), count(4, 0);
  for (int i = 0; i < n; ++i) {
    if (id[i] == 0) {
      if (cur == 4) {
        cout << "-1\n";
        return;
      }
      vector<int> ngb(n, 0);
      for (int v : g[i]) {
        ngb[v] = 1;
      }
      for (int j = 0; j < n; ++j) {
        if (ngb[j] == 0 && id[j]) {
          cout << "-1\n";
          return;
        } else if (ngb[j] == 0) {
          id[j] = cur;
          count[cur]++;
        }
      }
      ++cur;
    }
  }
  if (cur != 4) {
    cout << "-1\n";
    return;
  }
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int ngb : g[i]) {
      if (id[ngb] == id[i]) {
        cout << "-1\n";
        return;
      }
      ++cnt;
    }
    if (cnt != n - count[id[i]]) {
      cout << "-1\n";
      return;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << id[i] << ' ';
  }
  cout << '\n';
}
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int q = 1;
  for (int i = 0; i < q; ++i) {
    solve();
  }
}
