text: /**
   *    @author     : Maruf Tuhin
   *    @College    : CUET CSE 11
   *    @Topcoder   : the_redback
   *    @CodeForces : the_redback
   *    @UVA        : the_redback
   *    @link       : http://www.fb.com/maruf.2hin
   */
  
  #include <bits/stdc++.h>
  using namespace std;
  
  typedef long long          ll;
  typedef unsigned long long llu;
  
  #define ft         first
  #define sd         second
  #define mp         make_pair
  #define pb(x)      push_back(x)
  #define all(x)     x.begin(),x.end()
  #define allr(x)    x.rbegin(),x.rend()
  #define mem(a,b)   memset(a,b,sizeof(a))
  #define sf(a)      scanf("%lld",&a)
  #define ssf(a)     scanf("%s",&a)
  #define sf2(a,b)   scanf("%lld %lld",&a,&b)
  #define sf3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
  #define inf        1e9
  #define eps        1e-9
  #define mod        1000000007
  #define NN         100010
  
  #ifdef  redback
  #define bug printf("line=%d\n",__LINE__);
  #define debug(args...) {cout<<":: "; dbg,args; cerr<<endl;}
  struct  debugger{template<typename T>debugger& operator ,(const T& v){cerr<<v<<" ";return *this;}}dbg;
  #else
  #define bug
  #define debug(args...)
  #endif  //debugging macros
  
  ll a[100010];
  
  int main()
  {
      #ifdef redback
          freopen("C:\\Users\\Maruf\\Desktop\\in.txt","r",stdin);
      #endif
  
      ll t=1,tc;
      //sf(tc);
      ll l,m,n;
      while(~sf2(n,m)) {
          ll i,j,k;
          l=inf;
          for(i=0;i<m;i++)
          {
              sf2(j,k);
              l=min(l,k-j);
          }
          j=l;
          printf("%lld\n",l+1);
          for(i=0;i<n;i++,j--)
          {
              if(j<0)
                  j=l;
              if(i!=0)
                  printf(" ");
              printf("%lld",j);
          }
          printf("\n");
  
      }
      return 0;
  }
  