#include using namespace std; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0, i##_len=(n); i> a >> b >> c >> d; cout << (u64)((__int128_t)a * b * c % d) << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); run(); return 0; }