#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char rbuf[16]; #define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} char wbuf[11*200000]; #define MD 1000000007 long mp(long v,long b,long e){ while(e){ if(e&1) v=v*b%MD; b=b*b%MD; e>>=1; } return v; } main(){ read(0,rbuf,sizeof rbuf); char*rp=rbuf; RD(n); RD(m); ++n; char*wp=wbuf; for(int x=0;++x<=m;){ long a=n/x; long b=n%x; long v=mp(mp(a-1,a+1,b),a,x-b-1); char*wp1=wp; wp+=11; char*wp2=wp; *--wp2=10; while(*--wp2=v%10+48,v/=10); while(wp2!=wp1) *--wp2=32; if(!(x-m&0x1fff)){ write(1,wbuf,wp-wbuf); wp=wbuf; } } _exit(0); }