#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<vector<int> > G;
int all[300010], ans[300010];
int main() {
  int n, m, t1, t2;
  memset(all, 0, sizeof(all));
  vector<int> cnm;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    G.push_back(cnm);
  }
  for (int i = 0; i < m; ++i) {
    cin >> t1 >> t2;
    G[t1 - 1].push_back(t2 - 1);
    G[t2 - 1].push_back(t1 - 1);
  }
  for (int i = 0; i < n; ++i) {
    sort(G[i].begin(), G[i].end());
  }
  sort(G.begin(), G.end());
  G.erase(unique(G.begin(), G.end()), G.end());
  if (G.size() != 3) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < 3; ++i) {
    for (auto &it : G[i]) {
      all[it] |= (1 << i);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (__builtin_popcount(all[i]) != 2) {
      cout << "-1" << endl;
      return 0;
    }
    if (all[i] == 3)
      ans[i] = 1;
    else if (all[i] == 5)
      ans[i] = 2;
    else
      ans[i] = 3;
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  return 0;
}
