#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 3 * 1e5 + 15;
int cnt;
int n, m;
int x, y;
vector<int> G[MAXN];
int vis[MAXN], color[MAXN], deg[MAXN];
void dfs(int x) {
  vis[x] = cnt;
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    if (vis[y]) continue;
    dfs(y);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cnt++;
      dfs(i);
    }
  }
  if (cnt >= 2) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) color[i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      int v = G[i][j];
      if (color[i] != color[v])
        continue;
      else
        color[v]++;
    }
  }
  int cnt_one = 0, cnt_two = 0, cnt_three = 0;
  for (int i = 1; i <= n; i++) {
    if (color[i] == 1)
      cnt_one++;
    else if (color[i] == 2)
      cnt_two++;
    else
      cnt_three++;
  }
  if (cnt_one == 0 || cnt_two == 0 || cnt_three == 0) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (color[i] == 1 && deg[i] != n - cnt_one) {
      printf("-1\n");
      return 0;
    } else if (color[i] == 2 && deg[i] != n - cnt_two) {
      printf("-1\n");
      return 0;
    } else if (color[i] == 3 && deg[i] != n - cnt_three) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", color[i]);
  }
  printf("\n");
  return 0;
}
