#include <bits/stdc++.h>
using namespace std;
vector<long long int> lst[100005];
long long int deg[100005], c = 0, comp[100005];
long long int f(long long int n) {
  long long int i, j, k;
  long long int vis[100005] = {0};
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      comp[i] = c;
      long long int same[n + 1];
      for (j = 1; j <= n; j++) same[j] = 1;
      same[i] = 0;
      unordered_set<long long int> s;
      for (j = 0; j < lst[i].size(); j++) {
        long long int to = lst[i][j];
        s.insert(to);
        same[to] = 0;
      }
      for (j = 1; j <= n; j++) {
        if (same[j]) {
          if (deg[j] != deg[i]) return -1;
          for (k = 0; k < lst[j].size(); k++) {
            if (s.find(lst[j][k]) == s.end()) {
              return -1;
            }
          }
          comp[j] = c;
          vis[j] = 1;
        }
      }
      c++;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, n, m, u, v;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    lst[u].push_back(v);
    lst[v].push_back(u);
    deg[u]++;
    deg[v]++;
  }
  long long int x = f(n);
  if (x == -1 || c != 3)
    cout << -1 << "\n";
  else {
    for (i = 1; i <= n; i++) cout << comp[i] + 1 << " ";
    cout << "\n";
  }
  return 0;
}
