{
ZADATAK: prosim
JEZIK: pascal
}
program ProSim;
const
	MaxN = 100005;
var
  prost: array [1.. MaxN] of Boolean;
  b1, b2, x, y: array [1.. MaxN] of LongInt;
  SolA, SolB, a, b, n: LongInt;
  f, g: Text;

  procedure InPut;
  begin
  	Assign (f, 'prosim.in');
    Reset (f);
    ReadLn (f, a, b, n);
    Close (f);
  end;

  procedure Find_Prost;
  var
  	i, j: LongInt;
  begin
  	FillChar (prost, SizeOf (prost), True);
    prost [1] := False;
    for i := 1 to MaxN do
    	if (prost [i]) then begin
      	j := i + i;
        while (j <= MaxN) do begin
        	prost [j] := false;
          j := j + i;
        end;
      end;
  end;

  procedure SolveN;
  var
  	s, x1, y1, tmp, l, i, p, j, z, m, k, t, d: LongInt;
    ok: Boolean;
  begin
  	Find_Prost;
    SolA := a; SolB := b;
    for i := a to b do
    	for j := a to b do begin
      	p := i * j;
        z := i + j;
        m := 0;
        for k := 1 to z DIV 2 do begin
        	x1 := k; y1 := z - k;
          if (x1 >= a) and (x1 <= b) and (y1 >= a) and (y1 <= b) and (not prost [y1 * x1]) then
           	Inc (m);
        end;
        ok := False;
        if (m > 1) then
        	ok := True;
        if (ok) then begin
	        m := 0;
	        for k := 1 to p DIV 2 do begin
	        	t := p DIV k;
	          if (t * k = p) then
	          	if (k >= a) and (k <= b) and (t >= a) and (t <= b) then begin
	            	Inc (m);
	              x [m] := k;
	              y [m] := t;
	            end;
	        end;
	        d := 0;
	        for k := 1 to m do begin
	        	z := x [k] + y [k];
	          s := 0;
	          for l := 1 to z DIV 2 do begin
	          	x1 := l; y1 := z - l;
	            if (x1 < a) or (x1 > b) or (y1 < a) or (y1 > b) or (prost [y1 * x1]) then
	            	Inc (s);
	          end;
	          if (s = (z DIV 2) - 1) then
  	        	Inc (d);
     	     end;
	     	   if (d = 1) and (not prost [p]) then begin
        		 SolA := i;
	           SolB := j;
             if (SolA > SolB) then begin
             	 tmp := SolA;
               SolA := SolB;
               SolB := tmp;
             end;
           end;
         end;	
      end;
  end;

  procedure Solve;
  begin
  	SolA := 0; SolB := 0;
    if (a = b) or (a + 1 = b) then begin
    	SolA := a;
      SolB := b;
    end;
    if (SolA = 0) then
    	SolveN;
  end;

  procedure OutPut;
  begin
  	Assign (g, 'prosim.out');
    ReWrite (g);
    WriteLn (g, SolA, ' ', SolB);
    Close (g);
  end;

begin
	InPut;
  Solve;
  OutPut;
end.
