#include <bits/stdc++.h>
using namespace std;
int n,m;
long long a,b,br,res;
long long c[50005],d[50005];
long long niz[50005];
int main(){
  cin>>n>>m;
  cin>>a>>b;

  for(int i=1;i<=m;i++){
    cin>>c[i]>>d[i];
  }
  for(int i=1;i<=m;i++){
    if(b>c[i] and b>a and b<=d[i]){
    niz[i]=b;
    res++;
    br+=niz[i];
    }
    else if(d[i]>c[i] and d[i]>a and d[i]<=b){
    niz[i]=d[i];
    res++;
    br+=niz[i];
    }
    else niz[i]=c[i];


  }
  cout<<br<<endl;
  cout<<res<<endl;
  for(int i=1;i<=m;i++){
    cout<<niz[i]<<" ";
  }
  cout<<endl;



  return 0;
}