#include<iostream>
#define maxn 11
using namespace std;
#define ll long long
ll yushu[maxn],mod[maxn];
void excgcd(ll a,ll b,ll &x,ll &y){
if(b==0){
x=1;
y=0;
return;
}
ll x1,y1;
excgcd(b,a%b,x1,y1);
x=y1;
y=x1-(a/b)*y1;
return;
}
int main(){
ll s=1,l,r;
int n;
cin>>n>>l>>r;
for(int i=0;i<n;i++){
ll mo,yu;
cin>>mo>>yu;
yu=yu%mo;
s*=mo;
yushu[i]=yu;
mod[i]=mo;
}
ll ans=0;
for(int i=0;i<n;i++){
ll mi=s/mod[i];
ll x,y;
excgcd(mi,mod[i],x,y);
ans+=yushu[i]*mi*x;
}
while(ans>l){
ans-=s;
}
ll sum=0,minn=0;
for(int i=1;;i++){
ans+=s;
if(ans<=r){
if(ans>=l){
if(sum==0){
minn=ans;
}
sum++;
}
}
else break;
}
cout<<sum<<endl<<minn;
return 0;
}