#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd(v) long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);} #define rep(v,e) for(long v=0;v>=1; b=b*b%MD; } } pwmemo[d]=r; } a=r*(m-1)%MD*(MD+1>>1)%MD-a%MD; a=a*(n%MD)%MD*(m+1)%MD; a+=a<0?MD:0; char*wp=rwbuf+sizeof rwbuf; wt(a); write(1,wp,rwbuf+sizeof rwbuf-wp); _exit(0); }