#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 100500;
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;
int n, m;
vector<int> g[maxn];
set<int> used;
int num[maxn];
int cur_num = 0;
void dfs(int i) {
  used.erase(i);
  num[i] = cur_num;
  int last = 0;
  g[i].push_back(n + 1);
  sort((g[i]).begin(), (g[i]).end());
  for (int j : g[i]) {
    int l = last + 1;
    int r = j - 1;
    while (!used.empty()) {
      auto it = used.lower_bound(l);
      if (it == used.end() || *it > r) {
        break;
      }
      dfs(*it);
    }
    last = j;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    used.insert(i);
  }
  while (!used.empty()) {
    cur_num++;
    dfs(*used.begin());
  }
  if (cur_num != 3) {
    cout << -1 << endl;
    exit(0);
  }
  for (int i = 1; i <= n; ++i) {
    for (int x : g[i])
      if (x != n + 1 && num[x] == num[i]) {
        cout << -1 << endl;
        return 0;
      }
  }
  for (int i = 1; i <= n; ++i) {
    cout << num[i] << " \n"[i == n];
  }
}
