#include <bits/stdc++.h>
using namespace std;
struct comp {
  bool operator()(int a, int b) { return a > b; }
};
vector<int> node[100005];
int main() {
  int n, m, a, b, ans[100005];
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a, &b);
    node[a].push_back(b);
    node[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) ans[i] = 1;
  int size = (int)node[1].size();
  for (int i = 0; i <= size - 1; i++) ans[node[1][i]] = 2;
  if (size > 0) {
    int curNode = node[1][0];
    size = (int)node[curNode].size();
    for (int i = 0; i <= size - 1; i++)
      if (ans[node[curNode][i]] == 2) ans[node[curNode][i]] = 3;
  }
  int nodeCnt[4] = {};
  for (int i = 1; i <= n; i++) nodeCnt[ans[i]]++;
  bool valid = (nodeCnt[1] > 0 && nodeCnt[2] > 0 && nodeCnt[3] > 0);
  if (valid) {
    for (int i = 1; i <= n; i++) {
      int cnt[4] = {};
      size = (int)node[i].size();
      for (int j = 0; j <= size - 1; j++) cnt[ans[node[i][j]]]++;
      for (int j = 1; j <= 3; j++)
        if ((j == ans[i] && cnt[j] != 0) ||
            (j != ans[i] && cnt[j] != nodeCnt[j]))
          valid = false;
      if (!valid) break;
    }
  }
  if (!valid)
    printf("-1\n");
  else {
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
