#include <bits/stdc++.h>
using namespace std;
vector<set<int> > ad;
int main() {
  int m;
  long long n;
  scanf("%lld%d", &n, &m);
  int se[n], ed[m][2];
  ad.resize(n);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &ed[i][0], &ed[i][1]);
    ed[i][0]--;
    ed[i][1]--;
    ad[ed[i][0]].insert(ed[i][1]);
    ad[ed[i][1]].insert(ed[i][0]);
  }
  memset(se, 0, sizeof se);
  se[0] = 1;
  long long c1, c2;
  c1 = 1;
  for (int i = 1; i < n; i++)
    if (ad[0].count(i) <= 0) {
      se[i] = 1;
      c1++;
    }
  int i = 0;
  while (i < n && se[i] == 1) i++;
  if (i == n) {
    printf("-1\n");
    return 0;
  }
  se[i] = 2;
  c2 = 1;
  for (int j = 1; j < n; j++)
    if (j != i && ad[i].count(j) <= 0)
      if (se[j] == 0) {
        se[j] = 2;
        c2++;
      } else {
        printf("-1\n");
        return 0;
      }
  long long c3 = n - c1 - c2;
  if (c3 <= 0 || c1 * c2 + c2 * c3 + c1 * c3 != m) {
    printf("-1\n");
    return 0;
  }
  for (i = 0; i < m; i++)
    if (se[ed[i][0]] == se[ed[i][1]]) {
      printf("-1\n");
      return 0;
    }
  for (i = 0; i < n; i++) printf("%d\n", se[i] + 1);
  return 0;
}
