#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<long long> pw(n + 1), val(n + 1, 0);
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) {
    pw[i] = 19 * pw[i - 1];
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    val[u] += pw[v];
    val[v] += pw[u];
  }
  map<long long, long long> ma;
  for (int i = 1, cnt = 0; i <= n; ++i) {
    if (ma[val[i]] == 0) ma[val[i]] = ++cnt;
    if (val[i] == 0) {
      cout << -1 << '\n';
      return 0;
    }
  }
  if (ma.size() != 3)
    cout << -1 << '\n';
  else {
    for (int i = 1; i <= n; ++i) cout << ma[val[i]] << " ";
    cout << '\n';
  }
}
