#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long n, m, i, j, fa[300005], px[300005], py[300005], cnt1, cnt2, cnt3,
    col1, col2, col3;
vector<long long> ban[300005];
map<long long, long long> cnt;
long long fnd(long long x) {
  if (fa[x] == x) return x;
  return fa[x] = fnd(fa[x]);
}
int main() {
  read(n);
  read(m);
  for (((i)) = (1); ((i)) <= ((m)); ((i))++) {
    read(px[i]);
    read(py[i]);
    ban[px[i]].push_back(py[i]);
    ban[py[i]].push_back(px[i]);
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    fa[i] = i;
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    sort(ban[i].begin(), ban[i].end());
    for (j = 1; j <= n; j++) {
      if (j <= ban[i].size() && ban[i][j - 1] == j) continue;
      break;
    }
    if (j <= n) fa[fnd(j)] = fnd(i);
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    cnt[fnd(i)]++;
  }
  if (cnt.size() != 3) {
    puts("-1");
    return 0;
  }
  for (__typeof((cnt).begin()) it = (cnt).begin(); it != (cnt).end(); it++) {
    if (cnt2)
      cnt3 = it->second;
    else if (cnt1)
      cnt2 = it->second;
    else
      cnt1 = it->second;
    if (col2)
      col3 = it->first;
    else if (col1)
      col2 = it->first;
    else
      col1 = it->first;
  }
  if (m != cnt1 * cnt2 + cnt2 * cnt3 + cnt3 * cnt1) {
    puts("-1");
    return 0;
  }
  for (((i)) = (1); ((i)) <= ((m)); ((i))++) {
    if (fnd(px[i]) == fnd(py[i])) {
      puts("-1");
      return 0;
    }
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    if (fnd(i) == col1) printf("1 ");
    if (fnd(i) == col2) printf("2 ");
    if (fnd(i) == col3) printf("3 ");
  }
  return 0;
}
