#pragma GCC optimize ("Ofast") #include using namespace std; template inline S min_L(S a,T b){ return a<=b?a:b; } template inline S max_L(S a,T b){ return a>=b?a:b; } int m2; int m5; int o2; int o5; int in2; int in5; void input(void){ int x; scanf("%d",&x); in2 = in5 = 0; while(x%2==0){ in2++; x/=2; } while(x%5==0){ in5++; x/=5; } } void output(void){ int cTE1_r3A, xr20shxY; int x = 1; for(cTE1_r3A=(0);cTE1_r3A<(m2);cTE1_r3A++){ x *= 2; } for(xr20shxY=(0);xr20shxY<(m5);xr20shxY++){ x *= 5; } printf("%d\n",x); fflush(stdout); } int main(){ int mn; int mx; int fg = 0; input(); { auto KrdatlYV = (in2); auto ao_dF3pO = ( in5); m2 = KrdatlYV; m5 = ao_dF3pO; } input(); { auto tU__gIr_ = (in2); auto a2conNHc = ( in5); o2 = tU__gIr_; o5 = a2conNHc; } for(;;){ if( (m2+m5+o2+o5)%2 == 0 ){ mn =min_L(m2, m5); if(m2==7 && m5==9){ m2 = m5 = 9; } else if(mn < 7 && m2==mn){ m2++; } else if(mn < 7 && m5==mn){ m5++; } else if(m2 > 7){ m2--; } else{ m5++; } output(); if(m2==o2 && m5==o5){ return 0; } input(); { auto YREPHmFM = (in2); auto jZyWAPpY = ( in5); o2 = YREPHmFM; o5 = jZyWAPpY; } if(m2==o2 && m5==o5){ return 0; } continue; } mx =max_L(abs(m2-o2), abs(m5-o5)); if(m2+mx==o2){ m2++; } else if(m2-mx==o2){ m2--; } else if(m5+mx==o5){ m5++; } else{ m5--; } output(); if(m2==o2 && m5==o5){ return 0; } input(); { auto ZIeRIny5 = (in2); auto iMWUTgY_ = ( in5); o2 = ZIeRIny5; o5 = iMWUTgY_; } if(m2==o2 && m5==o5){ return 0; } continue; } return 0; } // cLay varsion 20200509-1 // --- original code --- // int m2, m5, o2, o5; // // int in2, in5; // void input(void){ // int x; // scanf("%d",&x); // in2 = in5 = 0; // while(x%2==0) in2++, x/=2; // while(x%5==0) in5++, x/=5; // } // // void output(void){ // int x = 1; // rep(m2) x *= 2; // rep(m5) x *= 5; // printf("%d\n",x); // fflush(stdout); // } // // // { // int mn, mx, fg = 0; // // input(); // (m2, m5) = (in2, in5); // input(); // (o2, o5) = (in2, in5); // // for(;;){ // if( (m2+m5+o2+o5)%2 == 0 ){ // mn = min(m2, m5); // if(m2==7 && m5==9){ // m2 = m5 = 9; // } else if(mn < 7 && m2==mn){ // m2++; // } else if(mn < 7 && m5==mn){ // m5++; // } else if(m2 > 7){ // m2--; // } else { // m5++; // } // output(); // if(m2==o2 && m5==o5) return 0; // input(); // (o2, o5) = (in2, in5); // if(m2==o2 && m5==o5) return 0; // continue; // } // // mx = max(abs(m2-o2), abs(m5-o5)); // if(m2+mx==o2){ // m2++; // } else if(m2-mx==o2){ // m2--; // } else if(m5+mx==o5){ // m5++; // } else { // m5--; // } // output(); // if(m2==o2 && m5==o5) return 0; // input(); // (o2, o5) = (in2, in5); // if(m2==o2 && m5==o5) return 0; // continue; // } // }