#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x = n + 1;
  while (m--) {
    int a, b;
    cin >> a >> b;
    x = min(x, b - a);
  }
  x++;
  cout << x << endl;
  for (int i = 0; i < n; i++) {
    cout << i % x << " ";
  }
  return 0;
}
