#include <bits/stdc++.h>
using namespace std;
set<int> a[101000];
int ans[101000];
bool used[101000];
int b[5], k[5];
bool f = true;
void dfs(int v, int mn) {
  used[v] = true;
  ans[v] = mn;
  b[mn] = v;
  k[mn]++;
  for (int i : a[v])
    if (!used[i]) {
      for (int j = 1; j <= 3; j++)
        if (j != mn && !a[i].count(b[j])) {
          dfs(i, j);
          break;
        }
      if (!used[i]) {
        used[i] = true;
        f = false;
      }
    } else if (ans[i] == mn)
      f = false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, n, m, bb, c;
  cin >> n >> m;
  b[1] = b[2] = b[3] = -1;
  for (i = 0; i < m; i++) {
    cin >> bb >> c;
    bb--;
    c--;
    a[bb].insert(c);
    a[c].insert(bb);
  }
  dfs(0, 1);
  if (k[1] == 0 || k[2] == 0 || k[3] == 0) f = false;
  for (i = 0; i < n; i++)
    if (!used[i] || ans[i] == 0 ||
        a[i].size() != k[1] + k[2] + k[3] - k[ans[i]])
      f = false;
  if (f)
    for (i = 0; i < n; i++) cout << ans[i] << ' ';
  else
    cout << -1;
  return 0;
}
