#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; #define CRP(t, x) const t &x #define OPL(t, x) bool operator<(CRP(t, x)) const #define FIL(x, v) memset(x, V, sizeof(x)) #define CLR(x) FIL(x, 0) #define NE1(x) FIL(x, -1) #define INF(x) FIL(x, 0x3f) #ifndef _DEBUG #define _DEBUG 0 #endif // !_DEBUG #define IFD if (_DEBUG) typedef long long ll, i64; const int N = 3e5 + 50; vector V[N]; int inSet[N]; set s[10]; bool check(set &s1, set &s2) { return true; } int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0, x, y; i < m; i++) scanf("%d%d", &x, &y), V[x].push_back(y), V[y].push_back(x); for (int i = 1; i <= n; i++) V[i].push_back(0), V[i].push_back(n + 1), sort(V[i].begin(), V[i].end()); int scnt = 0; for (int i = 1; i <= n; i++) if (!inSet[i]) { auto &S = s[scnt++]; auto &v = V[i]; if (scnt > 3) return puts("-1"), 0; for (int i = 1; i < v.size(); i++) for (int j = v[i - 1] + 1; j < v[i]; j++) S.insert(j), inSet[j] = scnt; } if (scnt != 3) return puts("-1"), 0; if (s[0].size() * s[1].size() + s[1].size() * s[2].size() + s[2].size() * s[0].size() != m) return puts("-1"), 0; for (int i = 0; i < 3; i++) for (int x : s[i]) for (int k = 1; k < V[x].size() - 1; k++) if (inSet[V[x][k]] == i + 1) return puts("-1"), 0; /*if (check(s[0], s[1]) && check(s[1], s[2]) && check(s[2], s[0])) for (int i = 1; i <= n; i++) printf("%d%c", inSet[i], " \n"[i == n]); else puts("-1");*/ for (int i = 1; i <= n; i++) printf("%d%c", inSet[i], " \n"[i == n]); return 0; }