#include <bits/stdc++.h>
using namespace std;
void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int N = 1e6;
const long long inf = 1e9 + 7;
const long double PI = acos(-1);
long long bin_pow(long long x, long long y) {
  long long res = 1, base = x;
  while (y) {
    if (y & 1) {
      res *= base;
      res %= inf;
    }
    base *= base;
    base %= inf;
    y /= 2;
  }
  return res;
}
int n, m;
int color[N];
vector<int> g[N];
vector<int> nums[5];
bool used[N];
void dfs(int v, int curcolor) {
  used[v] = 1;
  color[v] = curcolor;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to]) {
      continue;
    }
    dfs(to, 5 - curcolor);
  }
}
int main() {
  boost();
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < g[1].size(); i++) {
    color[g[1][i]] = 2;
  }
  for (int i = 1; i <= n; i++) {
    if (!color[i]) {
      color[i] = 1;
      used[i] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (color[i] == 1) {
      continue;
    }
    if (used[i]) {
      continue;
    }
    dfs(i, 2);
  }
  for (int i = 1; i <= n; i++) {
    nums[color[i]].push_back(i);
  }
  if (nums[1].size() * nums[2].size() + nums[1].size() * nums[3].size() +
          nums[2].size() * nums[3].size() !=
      m) {
    cout << -1;
    return 0;
  }
  if (!nums[1].size() || !nums[2].size() || !nums[3].size()) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (color[i] == color[g[i][j]]) {
        cout << -1;
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << color[i] << " ";
  }
}
