#include <bits/stdc++.h>
using namespace std;
using namespace std;
int inf = 0x3f3f3f3f;
const int maxn = 100010;
unsigned long long p = 2333;
vector<int> v[maxn];
unordered_map<unsigned long long, int> um;
int vis[maxn];
unsigned long long getHash(int u) {
  unsigned long long sum = 0;
  int sz = v[u].size();
  for (int i = 0; i < sz; ++i) sum = sum * p + v[u][i];
  return sum;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int flag = 0;
  for (int i = 1; i < n + 1; ++i) {
    if (!v[i].size()) {
      flag = 1;
      break;
    }
    sort(v[i].begin(), v[i].end());
  }
  if (flag) {
    puts("-1");
    return 0;
  }
  int cnt = 0;
  for (int i = 1; i < n + 1; ++i) {
    unsigned long long now = getHash(i);
    if (!um[now]) {
      ++cnt;
      vis[i] = cnt;
      um[now] = cnt;
    } else
      vis[i] = um[now];
    if (cnt > 3) break;
  }
  if (cnt != 3)
    puts("-1");
  else {
    for (int i = 1; i < n + 1; ++i) printf("%d ", vis[i]);
    puts("");
  }
}
