#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> A >> B >> C >> D; ll a = A % D; ll b = B % D; ll c = C % D; ll d = a * b % D; ll e = d * c % D; p(e); return 0; }