#include <bits/stdc++.h>
using namespace std;
int visited[100005];
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> v(n + 5);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].insert(b);
    v[b].insert(a);
  }
  set<int> s1, s2, s3;
  visited[1]++;
  s1.insert(1);
  for (auto j = v[1].begin(); j != v[1].end(); j++) {
    s2.insert(*j);
    visited[*j]++;
  }
  int vertex = *s2.begin();
  for (auto it = v[vertex].begin(); it != v[vertex].end(); it++) {
    visited[*it]++;
    int a = *it;
    if (s2.count(a) != 0) {
      s3.insert(a);
      s2.erase(a);
    } else {
      s1.insert(a);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      cout << -1;
      return 0;
    }
  }
  long long int a = s1.size(), b = s2.size(), c = s3.size();
  long long int temp = a * b + a * c + b * c;
  if (temp != m) {
    cout << -1;
    return 0;
  }
  for (auto it = s1.begin(); it != s1.end(); it++) {
    for (auto j = v[*it].begin(); j != v[*it].end(); j++) {
      if (s1.count(*j) != 0) {
        cout << -1;
        return 0;
      }
    }
  }
  for (auto it = s2.begin(); it != s2.end(); it++) {
    for (auto j = v[*it].begin(); j != v[*it].end(); j++) {
      if (s2.count(*j) != 0) {
        cout << -1;
        return 0;
      }
    }
  }
  for (auto it = s3.begin(); it != s3.end(); it++) {
    for (auto j = v[*it].begin(); j != v[*it].end(); j++) {
      if (s3.count(*j) != 0) {
        cout << -1;
        return 0;
      }
    }
  }
  int ans[n + 5];
  for (auto it = s1.begin(); it != s1.end(); it++) {
    ans[*it] = 1;
    for (auto it2 = s2.begin(); it2 != s2.end(); it2++) {
      ans[*it2] = 2;
      if (v[*it].count(*it2) == 0) {
        cout << -1;
        return 0;
      }
    }
  }
  for (auto it = s1.begin(); it != s1.end(); it++) {
    for (auto it2 = s3.begin(); it2 != s3.end(); it2++) {
      ans[*it2] = 3;
      if (v[*it].count(*it2) == 0) {
        cout << -1;
        return 0;
      }
    }
  }
  for (auto it = s2.begin(); it != s2.end(); it++) {
    for (auto it2 = s3.begin(); it2 != s3.end(); it2++) {
      if (v[*it].count(*it2) == 0) {
        cout << -1;
        return 0;
      }
    }
  }
  if (a == 0 || b == 0 || c == 0) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
