#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, mod = 1e9 + 7, INF = 0x3f3f3f3f;
const double eps = 1e-6;
int n, m;
int id[N];
vector<int> v[N];
bool st[N];
bool check() {
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!id[i]) {
      cnt++;
      id[i] = cnt;
      int s = 0;
      if (cnt > 3) return false;
      for (auto x : v[i]) st[x] = 1, s++;
      st[i] = 1;
      for (int j = 1; j <= n; j++)
        if (!st[j]) {
          if (id[j]) return false;
          id[j] = cnt;
          int sum = 0;
          for (auto x : v[j]) {
            if (!st[x]) return false;
            sum++;
          }
          if (sum != s) return false;
        }
      for (auto x : v[i]) st[x] = 0;
      st[i] = 0;
    }
  if (cnt < 3) return false;
  for (int i = 1; i <= n; i++) printf("%d ", id[i]);
  puts("");
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  if (!check()) puts("-1");
  return 0;
}
