#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> vc1, vc2, vc3;
vector<int> vc[maxn];
int vis[maxn], v[maxn];
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i <= n; i++) vc[i].clear();
    vc1.clear(), vc2.clear(), vc3.clear();
    memset(vis, 0, sizeof(vis));
    memset(v, 0, sizeof(v));
    for (int i = 0; i < m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      vc[x].push_back(y);
      vc[y].push_back(x);
    }
    vc1.push_back(1);
    int ans = 1;
    v[1] = 1;
    if (vc[1].size()) {
      int x = vc[1][0];
      v[x] = 2;
      ans++;
      vc2.push_back(x);
      for (int j = 1; j < vc[1].size(); j++) vis[vc[1][j]]++;
      int ff = 0;
      for (int j = 0; j < vc[x].size(); j++) {
        vis[vc[x][j]]++;
        if (vis[vc[x][j]] == 2) {
          vc3.push_back(vc[x][j]), v[vc[x][j]] = 3, ans++;
          ff = 1;
          break;
        }
      }
      if (!ff) {
        printf("-1\n");
        continue;
      }
      int vx[5];
      int f = 0;
      for (int i = 2; i <= n; i++) {
        if (ans == n) {
          for (int j = 1; j <= n; j++) printf("%d ", v[j]);
          printf("\n");
          f = 1;
          break;
        }
        if (v[i]) continue;
        vx[1] = vx[2] = vx[3] = 0;
        for (int j = 0; j < vc[i].size(); j++) {
          x = vc[i][j];
          vx[v[x]]++;
        }
        if (!vx[1]) {
          if (vx[2] == vc2.size() && vx[3] == vc3.size())
            v[i] = 1, ans++, vc1.push_back(i);
          else {
            f = 1;
            printf("-1\n");
            break;
          }
        } else if (!vx[2]) {
          if (vx[1] == vc1.size() && vx[3] == vc3.size())
            v[i] = 2, ans++, vc2.push_back(i);
          else {
            f = 1;
            printf("-1\n");
            break;
          }
        } else if (!vx[3]) {
          if (vx[1] == vc1.size() && vx[2] == vc2.size())
            v[i] = 3, ans++, vc3.push_back(i);
          else {
            f = 1;
            printf("-1\n");
            break;
          }
        } else {
          f = 1;
          printf("-1\n");
          break;
        }
      }
      if (!f) {
        if (ans == n) {
          for (int j = 1; j <= n; j++) printf("%d ", v[j]);
          printf("\n");
        } else
          printf("-1\n");
      }
    } else
      printf("-1\n");
  }
  return 0;
}
