#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<int> edge[maxn];
int nv[maxn];
int tmp[maxn];
long long cnt[10];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i += 1) {
    int x, y;
    cin >> x >> y;
    edge[x].push_back(y), edge[y].push_back(x);
  }
  int t = 0;
  for (int i = 1; i <= n; i += 1) {
    if (!nv[i]) {
      nv[i] = ++t;
      if (t >= 4) {
        cout << -1 << '\n';
        return 0;
      };
      memset(tmp, 0, sizeof(tmp));
      for (auto k : edge[i]) tmp[k] = 1;
      for (int j = 1; j <= n; j += 1) {
        if (j != i && !tmp[j] && nv[j]) {
          cout << -1 << '\n';
          return 0;
        };
        if (!tmp[j]) nv[j] = t;
      }
    }
  }
  if (t < 3) {
    cout << -1 << '\n';
    return 0;
  };
  for (int i = 1; i <= n; i += 1) {
    for (auto k : edge[i]) {
      if (nv[i] == nv[k]) {
        cout << -1 << '\n';
        return 0;
      };
    }
    ++cnt[nv[i]];
  }
  if (cnt[1] * cnt[2] + cnt[2] * cnt[3] + cnt[3] * cnt[1] != m) {
    cout << -1 << '\n';
    return 0;
  };
  for (int i = 1; i <= n; i += 1) {
    cout << nv[i] << ' ';
  }
  return 0;
}
