#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 30;
vector<int> v[N];
map<vector<int>, int> mp;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int b, a;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!v[i].size()) {
      cout << "-1";
      return 0;
    }
    sort(v[i].begin(), v[i].end());
    if (mp.find(v[i]) == mp.end()) {
      mp[v[i]] = ++cnt;
    }
    if (cnt > 3) {
      cout << "-1";
      return 0;
    }
  }
  if (cnt != 3) {
    cout << "-1";
    return 0;
  }
  for (int i = 1; i <= n; i++) cout << mp[v[i]] << " ";
}
