#include <bits/stdc++.h>
using namespace std;
struct node {
  int to, next;
} q[600005];
int head[300005], cnt = 1;
int d[300005];
vector<int> v1, v2;
void add(int x, int y) {
  q[cnt].to = y;
  q[cnt].next = head[x];
  head[x] = cnt++;
}
int main() {
  memset(head, -1, sizeof(head));
  int n, m, a, b;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    v1.push_back(a);
    v2.push_back(b);
    add(a, b);
    add(b, a);
  }
  d[1] = 1;
  int val;
  for (int i = head[1]; i != -1; i = q[i].next) {
    int v = q[i].to;
    d[v] = 2;
    val = v;
  }
  d[val] = 2;
  for (int i = head[val]; i != -1; i = q[i].next) {
    int v = q[i].to;
    if (d[v] == 2) {
      d[v] = 3;
    }
  }
  long long a1 = 0, a2 = 0, a3 = 0;
  for (int i = 1; i <= n; i++) {
    if (d[i] == 0 || d[i] == 1) {
      d[i] = 1;
      a1++;
    }
    if (d[i] == 2) {
      a2++;
    }
    if (d[i] == 3) {
      a3++;
    }
  }
  if (a1 == 0 || a2 == 0 || a3 == 0) {
    printf("-1\n");
    return 0;
  }
  if (a1 * a2 + a1 * a3 + a2 * a3 == m) {
    int flag = 1;
    for (int i = 0; i < m; i++) {
      if (d[v1[i]] == d[v2[i]]) {
        flag = 0;
        break;
      }
    }
    if (!flag) {
      printf("-1\n");
    } else {
      for (int i = 1; i <= n; i++) {
        printf("%d ", d[i]);
      }
      printf("\n");
    }
  } else {
    printf("-1\n");
  }
  return 0;
}
