// {In the Name of Allah, the Most Beneficent, the Most Merciful }
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
#define mp make_pair
#define pb push_back
#define pf push_front
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);
#define no cout<<"NO\n"
#define yes cout<<"YES\n"
#define el "\n"
int freq[27];
int main()
{
/**/IOS/**/
ll l,r,x,y,k;
ll m=1e9+7;
cin>>l>>r>>x>>y>>k;
ll sh=(l/k)%m;
ll sum1=((sh%m*x%m*k%m)%m+((sh-1)%m*y%m)%m)%m;
if(l%k!=0)
sum1+=(((l%k)%m*x%m)%m+y%m)%m;
ll sh1=(r/k)%m;
ll sum2=((sh1%(m)*x%(m)*k%(m))%(m)+((sh1-1)%m*y%m)%m)%m;
if(r%k!=0)
sum2+=(((r%k)%m*x%m)%m+y%m)%m;
ll ans =(sum1%(m))+(sum2%(m))%m;
cout<<ans<<endl;
}
Copy