#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> gr(n);
  for (int i = (int)0; i < (int)m; i++) {
    int v, u;
    cin >> v >> u, v--, u--;
    gr[v].push_back(u), gr[u].push_back(v);
  }
  vector<int> colors(n, -1);
  vector<int> cnt_colors(3);
  vector<set<int>> connected(3);
  for (int v = (int)0; v < (int)n; v++) {
    vector<int> cnt_possible_colors(3);
    for (int u : gr[v])
      if (colors[u] != -1) cnt_possible_colors[colors[u]]++;
    for (int i : {0, 1, 2}) {
      bool ok = true;
      for (int j = (int)0; j < (int)3; j++) {
        if (i == j && cnt_possible_colors[j]) ok = false;
        if (i != j) {
          if (cnt_possible_colors[j] != cnt_colors[j]) {
            ok = false;
          }
        }
      }
      if (ok) {
        colors[v] = i;
        cnt_colors[i]++;
        break;
      }
    }
    if (colors[v] == -1) return cout << -1, 0;
    for (int u : gr[v]) connected[colors[v]].insert(u);
  }
  for (int i = (int)0; i < (int)3; i++)
    if (!cnt_colors[i]) return cout << -1, 0;
  for (int i = (int)0; i < (int)n; i++) cout << colors[i] + 1 << " ";
  return 0;
}
