#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> pa[100005];
vector<char> color;
map<vector<int>, vector<int> > col;
void input() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    pa[u].push_back(v);
    pa[v].push_back(u);
  }
}
void solve() {
  for (int i = 1; i <= n; i++) {
    if (pa[i].size() == 0) continue;
    sort(pa[i].begin(), pa[i].end());
    col[pa[i]].push_back(i);
  }
  if (col.size() != 3) {
    cout << "-1";
    return;
  }
  int cnt = 1;
  vector<int> ans(n + 1, 0);
  map<vector<int>, vector<int> >::iterator it;
  for (it = col.begin(); it != col.end(); it++) {
    vector<int> z = it->second;
    for (auto zz : z) ans[zz] = cnt;
    cnt++;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == 0) {
      cout << "-1";
      return;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  input();
  solve();
}
