// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-6
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
using namespace std;
// mylittledoge
struct info {
int Q,P,K,H;
info( ) { }
info( int q, int p, int k, int h) { Q = q, P = p, K = k, H = h; }
bool operator< ( const info & A) const {
if ( Q ! = A.Q ) return Q < A.Q ;
if ( H ! = A.H ) return H < A.H ;
if ( P ! = A.P ) return P < A.P ;
return K < A.K ; }
} ;
map< info,bool > M;
map< info,info> ako;
bool poss( int Q, int P, int K, int H) {
if ( Q < 0 || H <= 0 ) return false ;
int Qa = Q;
for ( int i = 0 ; i < K; i++ ) {
int I = int ( round( Qa* ( P/ 100.0 ) + soclose) + soclose) ;
if ( I >= H) break ;
Qa = max( - 1 ,Qa+ I- H) ; }
if ( Qa > 0 ) return false ;
Qa = Q;
for ( int i = 0 ; i < K; i++ ) {
int I = int ( round( Qa* ( P/ 100.0 ) + soclose) + soclose) ;
if ( I >= max( 0 ,H- i) ) break ;
Qa = max( - 1 ,Qa+ I- max( 0 ,H- i) ) ; }
if ( Qa < 0 ) return false ;
if ( M.find ( info( Q,P,K,H) ) ! = M.end ( ) ) { return M[ info( Q,P,K,H) ] ; }
if ( K == 0 ) {
if ( Q ! = 0 ) M[ info( Q,P,K,H) ] = false ;
else M[ info( Q,P,K,H) ] = true ;
return M[ info( Q,P,K,H) ] ; }
int I = int ( round( Q* ( P/ 100.0 ) + soclose) + soclose) ;
if ( I >= H) {
M[ info( Q,P,K,H) ] = false ;
return false ; }
// if(M.size()%100 == 0) cout << Q << " " << K << " " << H << " " << M.size() << endl;
if ( poss( Q+ I- H,P,K- 1 ,H) ) {
ako[ info( Q,P,K,H) ] = info( Q+ I- H,P,K- 1 ,H) ;
M[ info( Q,P,K,H) ] = true ;
return true ; }
if ( poss( Q+ I- H,P,K- 1 ,H- 1 ) ) {
ako[ info( Q,P,K,H) ] = info( Q+ I- H,P,K- 1 ,H- 1 ) ;
M[ info( Q,P,K,H) ] = true ;
return true ; }
M[ info( Q,P,K,H) ] = false ;
return false ; }
int main( ) {
cin .sync_with_stdio ( 0 ) ;
cin .tie ( 0 ) ;
double q;
int P,K;
cin >> q >> P >> K;
int Q = int ( q* 100 + soclose) ;
int hiA = 0 , hiB = 2 * Q+ 1 ;
while ( hiB- hiA > 1 ) {
int Qa = Q, hi = ( hiA+ hiB) / 2 ;
for ( int i = 0 ; i < K; i++ ) {
int I = int ( round( Qa* ( P/ 100.0 ) + soclose) + soclose) ;
if ( I > hi && Qa > 0 ) break ;
Qa + = I- hi;
Qa = max( Qa,- 1 ) ; }
if ( Qa <= 0 ) hiB = hi;
else hiA = hi; }
int h = hiB+ 1000 ;
for ( int i = hiB+ 100 ; i >= max( 0 ,hiB- 100 ) ; i-- )
if ( poss( Q,P,K,i) ) h = min( h,i) ;
/* for(int i =0; i < K; i++) {
int a;
cin >> a;
int I =int(round(Q*(P/100.0)+soclose)+soclose);
Q +=I-a;
cout << a << " " << Q << "\n";}
cout << poss(66524126,85,2,79887306) << "\n";
*/ if ( h == hiB+ 1000 ) { cout << "Impossible\n " ; return 0 ; }
map< int ,int > ans;
for ( int k = 0 ; k < K; k++ ) {
info I = ako[ info( Q,P,K- k,h) ] ;
ans[ h] ++ ;
h = I.H ;
Q = I.Q ; }
cout << fixed << setprecision( 2 ) ;
for ( auto it = ans.rbegin ( ) ; it ! = ans.rend ( ) ; it++ ) {
cout << "$" << it- > ff/ 100 << "." ;
if ( ( it- > ff) % 100 < 10 ) cout << "0" ;
cout << it- > ff% 100 ;
cout << " for " << it- > ss << " year(s)\n " ; }
return 0 ; }
// look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