#include <bits/stdc++.h>
using namespace std;
int n, m, f, t, num[5];
int clr[100010], vis[100010];
vector<int> g[100010];
void dfs(int now) {
  for (int i = 0; i < g[now].size(); i++) {
    int nxt = g[now][i];
    if (clr[nxt] == clr[now]) {
      if (clr[now] == 3) {
        cout << -1 << endl;
        exit(0);
      } else {
        clr[nxt] = clr[now] + 1;
      }
    }
  }
  vis[now] = 1;
  for (int i = 0; i < g[now].size(); i++) {
    if (!vis[g[now][i]]) {
      dfs(g[now][i]);
    }
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &f, &t);
    g[f].push_back(t);
    g[t].push_back(f);
  }
  for (int i = 1; i <= n; i++) {
    clr[i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    num[clr[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (n - num[clr[i]] == g[i].size())
      continue;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (num[1] == 0 || num[2] == 0 || num[3] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d%c", clr[i], i == n ? '\n' : ' ');
  }
  return 0;
}
