#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<unordered_set<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  vector<int> d(n, -1);
  vector<int> cnt(3, 0);
  for (int color = 0; color < 3; color++) {
    int pos = -1;
    for (int i = 0; i < n; i++)
      if (d[i] == -1) {
        pos = i;
        break;
      }
    if (pos == -1) return cout << -1 << endl, 0;
    cnt[color]++;
    d[pos] = color;
    for (int i = 0; i < n; i++)
      if (i != pos && d[i] == -1 && !g[pos].count(i)) {
        d[i] = color;
        cnt[color]++;
      }
  }
  vector<vector<int>> groups(3);
  for (int i = 0; i < n; i++) {
    if (d[i] == -1) return cout << -1 << endl, 0;
    groups[d[i]].push_back(i);
  }
  int ff = 0;
  for (int gr1 = 0; gr1 < 3; gr1++)
    for (int gr2 = gr1 + 1; gr2 < 3; gr2++)
      for (int i : groups[gr1])
        for (int j : groups[gr2])
          if (!g[i].count(j))
            return cout << -1 << endl, 0;
          else
            ff++;
  if (ff != m) return cout << -1 << endl, 0;
  for (int i = 0; i < n; i++) cout << d[i] + 1 << ' ';
  cout << endl;
  return 0;
}
