#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(n + 1);
  vector<pair<long long, long long>> edge(m);
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> edge[i].first >> edge[i].second;
    v[edge[i].first].push_back(edge[i].second);
    v[edge[i].second].push_back(edge[i].first);
  }
  vector<long long> ans1(n + 1, 1);
  vector<long long> temp(n + 1, 0);
  for (long long i = 0; i < v[1].size(); i++) {
    ans1[v[1][i]] = 0;
  }
  for (long long i = 1; i <= n; i++) {
    if (ans1[i] == 0) {
      for (long long j = 0; j < v[i].size(); j++) {
        temp[v[i][j]] = -1;
      }
      for (long long j = 1; j <= n; j++) {
        if (temp[j] == -1) continue;
        if (ans1[j] == 1) {
          cout << -1;
          return 0;
        } else {
          ans1[j] = 2;
        }
      }
      break;
    }
  }
  vector<long long> temp1(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    if (ans1[i] == 0) {
      for (long long j = 0; j < v[i].size(); j++) {
        temp1[v[i][j]] = -1;
      }
      for (long long j = 1; j <= n; j++) {
        if (temp1[j] == -1) continue;
        if (ans1[j] == 1 || ans1[j] == 2) {
          cout << -1;
          return 0;
        } else {
          ans1[j] = 3;
        }
      }
      break;
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (ans1[i] == 0) {
      cout << -1;
      return 0;
    }
  }
  for (long long i = 0; i < m; i++) {
    if (ans1[edge[i].first] == ans1[edge[i].second]) {
      cout << -1;
      return 0;
    }
  }
  int f1 = 0, f2 = 0, f3 = 0;
  for (long long i = 1; i <= n; i++) {
    if (ans1[i] == 1) {
      f1 = 1;
    } else if (ans1[i] == 2)
      f2 = 1;
    else if (ans1[i] == 3)
      f3 = 1;
  }
  if (f1 * f2 * f3 == 0) {
    cout << -1;
    return 0;
  }
  vector<long long> b(3, 0);
  for (long long i = 1; i <= n; i++) {
    if (ans1[i] == 1) {
      b[0]++;
    } else if (ans1[i] == 2)
      b[1]++;
    else if (ans1[i] == 3)
      b[2]++;
  }
  for (long long i = 1; i <= n; i++) {
    if (v[i].size() != n - b[ans1[i] - 1]) {
      cout << -1;
      return 0;
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << ans1[i] << " ";
  }
  return 0;
}
