#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adj[100005];
int special[100005];
int col[100005];
bool vis[100005];
bool z = 1;
int tot = 0, edge = 0;
void dfs(int i, int c) {
  vis[i] = 1;
  col[i] = c;
  for (auto j : adj[i]) {
    if (!special[j]) {
      tot++;
      continue;
    }
    edge++;
    if (!vis[j])
      dfs(j, c ^ 1);
    else if (col[j] == c)
      z = 0;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (auto j : adj[1]) special[j] = 1;
  if (!(int)adj[1].size()) z = 0;
  for (int i = 1; i <= n; i++)
    if (special[i] && !vis[i]) dfs(i, 0);
  int cnt = 0, cnt1 = 0;
  for (int i = 1; i <= n; i++) {
    if (special[i]) {
      cnt++;
      if (col[i]) cnt1++;
    }
  }
  if (!z || (tot * 1ll) != (cnt * 1ll * (n - cnt)) || tot + edge / 2 != m ||
      edge == 0 || edge / 2 != cnt1 * 1ll * (cnt - cnt1))
    return cout << -1 << '\n', 0;
  for (int i = 1; i <= n; i++) {
    if (!special[i])
      cout << 3 << " ";
    else
      cout << col[i] + 1 << " ";
  }
  cout << '\n';
  return 0;
}
