#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char buf[32]; #define RDL(v) long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;} #define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;} #define WT(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);} #define MD 1000000007 #define INV3 ((MD+1)/3) main(){ read(0,buf,sizeof buf); char*rp=buf; RDL(n); if(n>=(MD-1)*2){ n=n%(MD-1)+(MD-1); } long z=1; for(long i=1l<<31;i>>=1;){ z=z*z%MD; if(n&i){ z=z*10%MD; } } z=(z*(INV3+1)+(MD-INV3))%MD; char*wp=buf; WT(z); write(1,buf,wp-buf); _exit(0); }