#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
const int maxn=200;
struct node{
int l,r;
} a[maxn];
int n,t,s,e;
inline bool judge(int x){
int sum=s-e;
for(int i=1;i<=n;i++){
int ks=max(a[i].l,x);
int js=min(a[i].r,t);
sum-=(js-ks+1);
}
cout<<x<<" "<<sum<<endl;
if(sum==0) return true;
else return false;
}
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
inline void work(){
n=read(); s=read(); e=read(); t=read();
for(int i=1;i<=n;i++) a[i].l=read(),a[i].r=read();
for(int i=t;i>=0;i--){
if(judge(i)){
cout<<i;
break;
}
}
}
signed main(){work();return 0;}
@flhuang @longlong666 @Liyanxi1028 @wjl1100 @little_QL @SiriusIV @wsy_I