#include #include #include #include int cmp(const void *a,const void *b){ if(*(int*)a>*(int*)b){return 1;} else if(*(int*)a<*(int*)b){return -1;} else {return 0;} } int min(int a,int b){ if(a>=b){return b;} return a; } //cww int main(void){ int a,b,c,d; int res; scanf("%d %d %d %d",&a,&b,&c,&d); a=a%d; b=b%d; c=c%d; res=a*b%d; res=res*c%d; printf("%d\n",res); }