#include <bits/stdc++.h>
using namespace std;
long long n, m, k, c, ans1, ans2, ans3, a[100005], dp[5];
pair<long long, long long> p[300005];
vector<long long> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (m == 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (long long i = 1; i <= m; i++) {
    cin >> p[i].first >> p[i].second;
    if (p[i].first == 1) {
      v.push_back(p[i].second);
    } else if (p[i].second == 1) {
      v.push_back(p[i].first);
    }
  }
  sort(v.begin(), v.end());
  v.push_back(n + 1);
  a[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (i != v[k]) {
      a[i] = 1;
    } else {
      k++;
    }
  }
  c = v[0];
  for (long long i = 1; i <= m; i++) {
    if (p[i].first == c && a[p[i].second] == 0) {
      a[p[i].second] = 2;
    } else if (p[i].second == c && a[p[i].first] == 0) {
      a[p[i].first] = 2;
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (a[i] == 0) {
      a[i] = 3;
    }
  }
  for (long long i = 1; i <= n; i++) {
    dp[a[i]]++;
  }
  if (dp[1] == 0 || dp[2] == 0 || dp[3] == 0 ||
      dp[1] * dp[2] + dp[2] * dp[3] + dp[1] * dp[3] != m) {
    cout << -1 << '\n';
    return 0;
  }
  for (long long i = 1; i <= m; i++) {
    if (a[p[i].first] == a[p[i].second]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << '\n';
}
