#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, m;
int ans[N + 10];
vector<int> h[4];
vector<int> g[N + 10];
set<pair<int, int> > myset;
bool ok(int k1, int k2) {
  int len1 = h[k1].size();
  int len2 = h[k2].size();
  for (int i = 0; i < len1; i++)
    for (int j = 0; j < len2; j++) {
      int x = h[k1][i], y = h[k2][j];
      if (myset.find(make_pair(x, y)) == myset.end()) return false;
    }
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    ans[i] = 1;
  }
  int len = g[1].size();
  for (int i = 0; i < len; i++) {
    int y = g[1][i];
    ans[y] = 2;
  }
  int z = -1;
  for (int i = 1; i <= n; i++)
    if (ans[i] == 2) {
      z = i;
      break;
    }
  if (z == -1) {
    printf("-1");
    return 0;
  }
  len = g[z].size();
  for (int i = 0; i < len; i++) {
    int y = g[z][i];
    if (ans[y] == 2) {
      ans[y] = 3;
    }
  }
  for (int i = 1; i <= n; i++) h[ans[i]].push_back(i);
  if (h[3].empty()) {
    printf("-1");
    return 0;
  }
  int n1 = h[1].size(), n2 = h[2].size(), n3 = h[3].size();
  if (n1 * n2 + n1 * n3 + n2 * n3 != m) {
    printf("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    len = g[i].size();
    for (int j = 0; j < len; j++) {
      int y = g[i][j];
      myset.insert(make_pair(i, y));
    }
  }
  if (ok(1, 2) && ok(1, 3) && ok(2, 3)) {
  } else {
    printf("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
