#include <cstdio>
#include <algorithm>
using namespace std;
long long n,a,b,c,d,st,len,t[300010];
int q[300010];
int main()
{
scanf(“%lld%lld%lld%lld%lld%lld%lld”,&n,&a,&b,&c,&d,&st,&len);
for (int i=1;i<=n;i++) scanf(“%lld%d”,&t[i],&q[i]);
t[0]=-1;
int now=1;
long long change_rating=0,Min=0,rating=st;
for (int i=1;i<=n;i++)
{
while (now<=n&&t[now]-t[i]<len)
{
change_rating+=(q[now]?c:-d);
Min=min(Min,change_rating);
now++;
}
if (Min+rating>=0)
{
printf(“%lld\n”,t[i-1]+1);
return 0;
}
change_rating-=(q[i]?c:-d);
Min-=(q[i]?c:-d);
rating+=(q[i]?a:-b);
if (rating<0)
{
printf(“-1\n”);
return 0;
}
}
printf(“%lld\n”,t[n]+1);
return 0;
}