#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int mxN = 3e5 + 5;
template <class T>
T gcd(T a, T b) {
  return ((b == 0) ? a : gcd(b, a % b));
}
vector<int> g[mxN];
int col[mxN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  set<int> st(g[0].begin(), g[0].end());
  int f = 0;
  int num1 = 0, num2 = 0, num3 = 0;
  for (int i = 0; i < (int)(n); i++)
    if (st.find(i) == st.end()) {
      col[i] = 1;
      f |= 1;
      num1++;
    }
  int gd = -1;
  for (int i = 0; i < (int)(n); i++)
    if (!col[i]) gd = i;
  set<int> st1(g[gd].begin(), g[gd].end());
  for (int i = 0; i < (int)(n); i++)
    if (st1.find(i) == st1.end()) {
      if (col[i]) {
        cout << -1 << endl;
        return 0;
      }
      col[i] = 2;
      num2++;
      f |= 2;
    }
  for (int i = 0; i < (int)(n); i++)
    if (!col[i]) col[i] = 3, f |= 4, num3++;
  if (f < 7) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(n); i++) {
    int nm1 = 0, nm2 = 0, nm3 = 0;
    for (int j : g[i]) {
      if (col[j] == 1) nm1++;
      if (col[j] == 2) nm2++;
      if (col[j] == 3) nm3++;
    }
    if (col[i] == 1) {
      if (nm1 || nm2 != num2 || nm3 != num3) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (col[i] == 2) {
      if (nm1 != num1 || nm2 || nm3 != num3) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (col[i] == 3) {
      if (nm1 != num1 || nm2 != num2 || nm3) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) cout << col[i] << " ";
  cout << endl;
  return 0;
}
