#include <bits/stdc++.h>
using namespace std;
using llu = unsigned long long;
const int N = 1e5 + 10;
int n, m;
llu h[N], ngh[N];
int ans[N];
int main() {
  scanf("%d%d", &n, &m);
  llu All = 0;
  h[0] = 1;
  for (auto i = 1, _end = n; i <= _end; ++i) {
    h[i] = h[i - 1] * 2345678901239ll;
    All ^= h[i];
  }
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    ngh[u] ^= h[v];
    ngh[v] ^= h[u];
  }
  map<llu, int> S;
  for (auto u = 1, _end = n; u <= _end; ++u) S.insert({ngh[u], 0});
  int cnt = 0;
  for (auto &s : S) s.second = ++cnt;
  if (cnt != 3) return puts("-1"), 0;
  llu g[4] = {};
  for (auto u = 1, _end = n; u <= _end; ++u) {
    ans[u] = S[ngh[u]];
    g[ans[u]] ^= h[u];
  }
  assert((g[1] ^ g[2] ^ g[3]) == All);
  for (auto i = 1, _end = 3; i <= _end; ++i)
    if (S[All ^ g[i]] != i) return puts("-1"), 0;
  for (auto u = 1, _end = n; u <= _end; ++u)
    printf("%d%c", ans[u], " \n"[u == n]);
}
