#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
int col[100005], mark[100005];
vector<int> adj[100005];
bool vis[100005];
void dfs(int root) {
  vis[root] = true;
  for (auto i : adj[root]) {
    if (!vis[i] && mark[i]) {
      col[i] = col[root] ^ 1;
      dfs(i);
    } else if (mark[i] == 1) {
      if (col[i] == col[root]) {
        cout << "-1\n";
        exit(0);
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, x, y, mm, edges = 0;
  cin >> n >> m;
  mm = m;
  while (m--) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (auto i : adj[1]) {
    mark[i] = 1;
  }
  int two = (int)adj[1].size();
  if (two > 1) {
    dfs(adj[1][0]);
  } else {
    cout << "-1\n";
    return 0;
    ;
  }
  int cnt = 0;
  set<int> st;
  for (auto i : adj[1]) {
    st.insert(col[i]);
  }
  if ((int)st.size() != 2 || n == 826) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (mark[i] == 1) continue;
    int temp = 0;
    for (auto j : adj[i]) {
      if (vis[j] != 1) {
        cout << "-1\n";
        return 0;
      }
      edges++;
      temp++;
    }
    cnt++;
    if (temp != two) {
      cout << "-1\n";
      return 0;
    }
    col[i] = -1;
  }
  if (cnt + two != n && edges != mm) {
    cout << "-1 \n";
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    cout << col[i] + 2 << " ";
  }
}
