#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; int main(){ ll a, b, c, d, ans; cin >> a >> b >> c >> d; ans=(a*b)%(1000000007); ans*=c; ans%=1000000007; cout << ans%d << endl; return 0; }