#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, check[100001], cnt = 0, ans = 1;
  cin >> n >> m;
  vector<int> node[n + 1], v;
  while (m--) {
    int x, y;
    cin >> x >> y;
    node[x].push_back(y);
    node[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    long long hash = 0;
    for (long long i2 : node[i]) {
      hash = (hash + i2 * i2 * i2) % mod;
    }
    check[i] = hash;
    if (!count(v.begin(), v.end(), hash)) {
      v.push_back(hash);
      cnt += node[i].size();
    }
    if (v.size() > 3) {
      ans = 0;
      break;
    }
  }
  if (cnt != 2 * n) ans = 0;
  if (ans == 0 or v.size() != 3)
    cout << -1;
  else {
    for (long long i = 1; i <= n; i++) {
      for (long long i2 = 0; i2 < 3; i2++) {
        if (check[i] == v[i2]) cout << i2 + 1 << " ";
      }
    }
  }
}
