program roman (tty);
 
var  x, y  : integer;
begin   y := 1;
	repeat  x := y;  write(tty, x,' ');
	    while x >= 1000 do
		begin  write(tty, 'M');  x := x-1000  end;
	    if x >= 500 then
		begin  write(tty, 'D');  x := x-500  end;
	    while x >= 100 do
		begin  write(tty, 'C');  x := x-100  end;
	    if x >= 50 then
		begin  write(tty, 'L');  x := x-50  end;
	    while x >= 10 do
		begin  write(tty, 'X');  x := x-10  end;
	    if x >= 5 then
		begin  write(tty, 'V');  x := x-5  end;
	    while x >= 1 do
		begin  write(tty, 'I');  x := x-1  end;
	    writeln (tty) ;
	    y := 2*y
	until y > 5000
end.
