#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200009;
const long long MOD = 1e9 + 7;
class {
 public:
  int n, m;
  vector<int> V[MAXN];
  int f[MAXN];
  void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      V[u].push_back(v);
      V[v].push_back(u);
    }
    vector<int> S[3];
    int j = 0;
    for (int i = 1; i <= n; ++i) {
      if (f[i] == 0) {
        if (j == 3) {
          cout << -1;
          return;
        }
        vector<int> g(n + 9);
        for (int jj : V[i]) g[jj] = 1;
        for (int jj = 1; jj <= n; ++jj)
          if (!g[jj]) S[j].push_back(jj), f[jj] = 1;
        ++j;
      }
    }
    if (j != 3 || S[0].size() + S[1].size() + S[2].size() != n) {
      cout << -1;
      return;
    }
    for (int i = 0; i < 3; ++i) {
      for (int j : S[i]) f[j] = i;
    }
    for (int i = 1; i <= n; ++i) {
      int sz = S[(f[i] + 1) % 3].size() + S[(f[i] + 2) % 3].size();
      if (V[i].size() != sz) {
        cout << -1;
        return;
      }
      for (int j : V[i]) {
        if (f[j] == f[i]) {
          cout << -1;
          return;
        }
      }
    }
    for (int i = 1; i <= n; ++i) {
      cout << f[i] + 1 << " ";
    }
  }
} NSPACE;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}
