#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> g[maxn];
int n, m, num[4];
int dfn[maxn], sz, f[maxn], vis[maxn], val[maxn];
int color[maxn];
bool dfs(int u, int fa, int v) {
  color[u] = v;
  for (auto it : g[u]) {
    if (it == fa) continue;
    if (!vis[it]) continue;
    if (color[it] == color[u])
      return true;
    else if (!color[it]) {
      bool f = dfs(it, u, v % 2 + 1);
      if (f) return f;
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      color[i] = 3;
      for (auto it : g[i]) vis[it] = 1;
    }
  }
  bool f = false;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      f = dfs(i, 0, 1);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!color[i]) f = true;
  }
  if (f)
    puts("-1");
  else {
    for (int i = 1; i <= n; i++) num[color[i]]++;
    for (int i = 1; i <= n; i++) {
      if (color[i] == 3) {
        int n1 = 0, n2 = 0;
        for (auto it : g[i]) {
          if (color[it] == 1)
            n1++;
          else if (color[it] == 2)
            n2++;
        }
        if (n1 != num[1] || n2 != num[2]) f = true;
      }
      if (color[i] == 2) {
        int n1 = 0, n3 = 0;
        for (auto it : g[i]) {
          if (color[it] == 1)
            n1++;
          else if (color[it] == 3)
            n3++;
        }
        if (n1 != num[1] || n3 != num[3]) f = true;
      }
      if (color[i] == 1) {
        int n2 = 0, n3 = 0;
        for (auto it : g[i]) {
          if (color[it] == 3)
            n3++;
          else if (color[it] == 2)
            n2++;
        }
        if (n2 != num[2] || n3 != num[3]) f = true;
      }
    }
    if (f || !num[1] || !num[2] || !num[3])
      puts("-1");
    else {
      for (int i = 1; i <= n; i++) {
        if (i - 1) printf(" ");
        printf("%d", color[i]);
      }
    }
  }
  return 0;
}
