/**
n m
a1 b1
...
am bm
*/
#include <cstdio>
#include <ctime>
#include <vector>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
const int N = 1e5;
vector<int> c[N], List[N];
int n, m, cc, u[N];
void dfs( int v ) { // O(V)
List[cc-1].push_back(v);
u[v] = cc;
for (auto x : c[v]) // O(E)
if (!u[x])
dfs(x);
}
int main() {
scanf("%d%d", &n, &m);
forn(i, m) {
int a, b;
scanf("%d%d", &a, &b), a--, b--; // 0..n-1
c[a].push_back(b);
c[b].push_back(a);
}
forn(i, n)
if (!u[i])
cc++, dfs(i);
printf("%d\n", cc);
forn(i, n)
printf("%d ", u[i]);
fprintf(stderr, "time = %.2f\n", 1. * clock() / CLOCKS_PER_SEC);
}