#include <bits/stdc++.h>
using namespace std;
int print1() {
  cout << -1 << endl;
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > e(n);
  int a, b;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<int> c(n, 0);
  vector<int> cnt(3, 0);
  cnt[0] = n;
  for (auto &v : e[0]) {
    c[v] = 2;
    cnt[0]--;
    cnt[2]++;
  }
  for (a = 0; a < n && c[a] == 0; ++a)
    ;
  if (a == n) return print1();
  for (auto &v : e[a]) {
    if (c[v] == 2) {
      c[v] = 1;
      cnt[1]++;
      cnt[2]--;
    }
  }
  for (int j = 0; j < 3; ++j)
    if (cnt[j] == 0) return print1();
  vector<int> loc(3, 0);
  for (int i = 0; i < n; ++i) {
    loc[0] = 0;
    loc[1] = 0;
    loc[2] = 0;
    for (auto &v : e[i]) loc[c[v]]++;
    if (loc[c[i]] != 0) return print1();
    for (int j = 0; j < 3; ++j)
      if (c[i] != j && loc[j] != cnt[j]) return print1();
  }
  for (int i = 0; i < n; ++i) cout << c[i] + 1 << " ";
  cout << endl;
  return 0;
}
