#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
vector<int> vec[maxn];
int vis[maxn];
int cc[5];
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    vec[x].emplace_back(y);
    vec[y].emplace_back(x);
  }
  vis[1] = 2;
  for (auto it : vec[1]) {
    vis[it] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) vis[i] = 2;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 1) {
      for (auto it : vec[i]) {
        if (vis[it] == 1) vis[it] = 3;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cc[vis[i]]++;
  }
  bool f = 1;
  if (!cc[1] || !cc[2] || !cc[3]) f = 0;
  for (int i = 1; i <= n; i++) {
    for (auto it : vec[i])
      if (vis[it] == vis[i]) f = 0;
    int sum = 0;
    for (int j = 1; j <= 3; j++) {
      if (j != vis[i]) sum += cc[j];
    }
    if (sum != vec[i].size()) f = 0;
  }
  if (f)
    for (int i = 1; i <= n; i++) cout << vis[i] << ' ';
  else
    cout << -1;
  return 0;
}
