program p633b;
var
m,j,k:longint;
i:integer;
const five:byte=5;

procedure output(k: longint);
var i:longint;
begin
    writeln(five);
    for i:=0 to 4 do
        write(k*five+i,' ')
end;

begin
readln(m);
j:=0; i:=0;
while(j<m) do
    begin
    i:=i+1;
    k:=i*five;
    while(k mod five = 0) do
        begin
        j:=j+1;
        k:=k div five;
        end;
    end;
if j=m then output(i)
    else writeln(0)
end.

Program rfg;
Var n:cardinal;
    i:cardinal;
    res,l,r:cardinal;

 Begin
  readln(n);
  res:=0;
   for i:=1 to 1000000 do begin
      r:=i;
      While r mod 5=0 do begin inc(res); r:=r div 5; end;
      if (res>=n) then break;

   end;
  if res>n then writeln(0) else begin
    writeln(5);
    for l:=0 to 3 do write(i+l,' ');
    Writeln(i+4);

  End;
 End.

const fi = '';
      fo = '';
var i, j, a, m, so, n: longint;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);

  so:=0;  m:=0;
  readln(n);
  for i:=1 to n do
    begin
      m:=m+5;
      a:=i*5;
      while (a mod 5 = 0) and (a > 0) do
        begin
          inc(so);
          a:=a div 5;
        end;
      if so >= n then break
    end;
  if so = n then
    begin
      writeln(5);
      writeln(m,' ',m+1,' ',m+2,' ',m+3,' ',m+4);
    end
  else write(0);

  close(input); close(output);
end.

Const Finp='';
      Fout='';
Var n,k:longint;

Procedure Nhap;
Var f:Text;
    i:longint;
Begin
    assign(f,finp); reset(f);
    read(f,n);
    close(f);
End;
Procedure Solve;
Var i,d,temp:longint;
Begin
    d:=0; i:=5; k:=0;
    Repeat
        if i mod 5=0 then
            begin
                temp:=i;
                while temp mod 5=0 do
                    begin
                        inc(d);
                        temp:=temp div 5;
                    end;
                if d>n then
                    begin
                        k:=-1;
                        break;
                    end;
                if d=n then
                    begin
                        k:=i;
                        break;
                    end;
            end;
        inc(i);
    Until False;
End;
Procedure Xuat;
Var f:Text;
    i:longint;
Begin
    assign(f,fout); rewrite(f);
    if k=-1 then
        write(f,0)
    else
        begin
            writeln(f,5);
            for i:=0 to 4 do
                write(f,k+i,' ');
        end;
    close(f);
End;

Begin
    nhap;
    solve;
    xuat;
End.

Var m,k,i,u:Longint;
Begin
  Readln(m);
  k:=0;i:=0;
  While k<m do
    Begin
      Inc(i);
      If i mod 5=0 then
        Begin
          u:=i;
          While u mod 5=0 do
            Begin
              Inc(k);
              u:=u Div 5;
            End;
        End;
    End;
  If k=m then
    Begin
      Writeln(5);
      For u:=0 to 4 do
        Write(i+u,' ');
    End
  Else
    Writeln(0);
End.

var
n,m,k,l,i:longint;
begin
read(n);
  for i:=1 to 10000000 do
   begin
    l:=i;
    while l>=5 do
     begin
      if l mod 5 <>0 then break;
      inc(k);
      l:=l div 5;
     end;
    if k=n then begin
                 writeln(5);
                 for m:=0 to 4 do write(i+m, ' ');
                 halt;
                end;
   end;
     write(0);
end.

var
    m,n,tong,p,i,dem:longint;
    kq:array[0..600000] of longint;
begin
    readln(m);
    n:=0;
    while tong<=m do
    begin
        inc(n);
        p:=n;
        while p>0 do
        begin
            if p mod 5<>0 then break;
            tong:=tong+1;
            p:=p div 5;
        end;
        if tong=m then
        begin
            inc(dem);
            kq[dem]:=n;
        end;
    end;
    writeln(dem);
    for i:=1 to dem do write(kq[i],' ');
end.

{$mode objfpc}
{$macro on}
{$define maicute:= for i := 1 to n do}

uses
  Math;

const
  inp  = '';
  outp = '';
  maxN = round(1e6);

var
  fi, fo : textfile;
  n, m  : Integer;
  a, b, s, f1, f2 : array[0..maxN] of Int64;

Procedure OpenFile;
begin
  Assign(fi, inp); Reset(fi);
  Assign(fo, outp); Rewrite(fo);
end;

Procedure Init;
begin
  fillchar(a, sizeof(a), 0);
  fillchar(b, sizeof(b), 0);
  fillchar(f1 , sizeof(f1), 0);
  fillchar(f2, sizeof(f2), 0);
end;

Procedure Enter;
var
  i, j : Integer;
begin
  ReadLn(fi, m);
end;

function get2(x : Integer): Integer;
begin
  result := 0;
  while x mod 2 = 0 do
    begin
      x := x div 2;
      result := result + 1;
    end;
end;

function get5(x : Integer): integer;
begin
  result := 0;
  while x mod 5 = 0 do
    begin
      x := x div 5;
      result := result + 1;
    end;
end;

Procedure Solve;
var
  i, j : Integer;
  res : Integer;
begin
  a[2] := 1;
  for i := 3 to 1000000 do
    if i mod 2 = 0 then
      a[i] := a[i-1] + get2(i)
    else a[i] := a[i-1];
  b[5] := 1;
  for i := 6 to 1000000 do
    if i mod 5 = 0 then
      b[i] := b[i-1] + get5(i)
    else b[i] := b[i-1];
  res := 0;
  for i := 1 to 1000000 do
    if min(a[i], b[i]) = m then
      begin
        inc(res);
        s[res] := i;
      end
    else if min(a[i], b[i]) > m then break;
  Writeln(fo, res);
  for i := 1 to res do write(s[i],' ');
end;

Procedure PrintResult;
begin
end;

Procedure Closefile;
begin
  close(fi); close(fo);
end;

Begin
  OpenFile;
  Init;
  Enter;
  Solve;
  Printresult;
  Closefile;
End.

var a:array[0..200000]of longint;n,i,k,c,b:longint;
begin
read(n);
k:=5;a[1]:=5;c:=1;
while c<=n do
begin
k:=k+5;
if (k) mod 25>0 then begin inc(c);a[c]:=k;end else
begin
  b:=k;
  while b mod 5=0 do begin inc(c); b:=b div 5;end;a[c]:=k;
end; end;
 if a[n]=0 then write(0) else
 begin
   writeln(5);
   for i:=0 to 4 do
   write(a[n]+i,' ');

 end;
end.

program ex;
var i,j,l,m,n,g:integer;
    k,h:longint;
    a:array[1..100200]of integer;
begin

  read(m);
  for i:=1 to 100200 do
  a[i]:=0;
  j:=1;
  k:=5;
  a[1]:=k;
  while(m>j) do
  begin
    k:=k+5;
    h:=5;  l:=0;
    while(k mod h =0) do
    begin

    h:=h*5;
    l:=l+1;
    end;
    h:=h div 5;
    j:=j+l;
    a[j]:=k;
  end;

  if a[m]=0
  then write(0)
  else begin
  writeln(5);
  writeln(a[m],' ',a[m]+1,' ',a[m]+2,' ',a[m]+3,' ',a[m]+4);
  end;

end.

Program Buntarik;
uses math;
var x,i,kol,k,ans,n:int64;

begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }

readln(n);  k:=0;
i:=5;
while k=0 do
 begin
  x:=i; kol:=0;
  while x mod 5=0 do
   begin
   inc(kol);
   x:=x div 5;
   end;
  inc(ans,kol);
  if ans=n
  then begin writeln(5); writeln(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4); halt; end
  else if ans>n then break;
  inc(i,5);
 end;
 writeln(k);

{close(input);   close(output); }
end.

Program _1;
Var
   m,kol,nom,i,j:longint;
   a:array[1..10] of longint;
Begin
   {assign(input,'input.txt');
   assign(output,'output.txt');
   reset(input);
   rewrite(output);}
   read(m);
   kol:=0;
   i:=1;
   while kol<=m do begin
                   j:=i;
                   while j mod 5 = 0 do begin
                                        inc(kol);
                                        j:=j div 5;
                                        end;
                   if kol=m then begin
                                 inc(nom);
                                 a[nom]:=i;
                                 end;
                   inc(i);
                   end;
   if nom=0 then write(0)
            else begin
                 writeln(nom);
                 for j:=1 to nom do write(a[j],' ');
                 end;
End.

uses math;

var
 res:array[0..1000000]of longint;
 i,m,n,k,l,w,s,j,w1,w2,w3:longint;
begin
 readln(n);
 for i:=1 to 10000000 do
 begin
  s:=i;
  while s mod 2=0 do begin inc(w1); s:=s div 2; end;
  while s mod 5=0 do begin inc(w2); s:=s div 5; end;
  l:=min(w1,w2);
  dec(w1,l); dec(w2,l); inc(w3,l);
  if w3=n then begin inc(k); res[k]:=i; end;
  if w3>n then break;
 end;
 writeln(k);
 for i:=1 to k do write(res[i],' ');
end.

uses math;
var i,t,kol1,kol2,n,kol:longint;
    a:array[1..10000] of longint;
begin
readln(n);
for i:=1 to 1000000 do
begin
t:=i;
  while(t mod 2=0) do
  begin
  inc(kol1);
  t:=t div 2;
  end;
     while(t mod 5=0) do
     begin
     inc(kol2);
     t:=t div 5;
     end;

if min(kol1,kol2)=n then begin inc(kol); a[kol]:=i; end;

end;

writeln(kol);
for i:=1 to kol do
write(a[i],' ');

end.

uses math;
var a:array[0..1000001] of int64;
    pr,ind,p,d,n:int64;i:longint;

procedure dv(x:longint);
begin
 while (x mod 2=0)do
 begin x:=x div 2;inc(d);end;

 while (x mod 5=0)do
 begin x:=x div 5;inc(p);end;

end;

begin
readln(n);

i:=1;

while(pr<>1)do
begin
inc(i);
dv(i);
if min(p,d)>n then break else
if min(p,d)=n then begin inc(ind);a[ind]:=i;end;
end;

writeln(ind);
for i:=1 to ind do
write(a[i],' ');

end.

var
	n,m,k,l,j,i:longint;
begin
	read(n);
	for i:=1 to 1000000 do
	begin
		l:=i;
		while l>=5 do
		begin
			if l mod 5 <>0 then break;
			inc(k);
			l:=l div 5;
		end;
		if k=n then
		begin
			writeln(5);
			for m:=0 to 4 do write(i+m, ' ');
			j:=1;
		end;
		if j=1 then exit;
    end;
    write(0);
end.

Var a:array[1..12000] of longint;
 n,i,l,r,m:longint;
 function check(n:longint):Longint;

  Var a:array[1..10000] of int64;
      d,k,ans,m:int64;
      i,j:longint;
  Begin
   //Read(n);
   ans:=0;
   a[1]:=5;
   d:=a[1];
   i:=2;
   m:=1;
   while a[i]<=n do
     Begin
      a[i]:=a[i-1]*5;
      if (a[i]>n) then break;
      inc(i);
      inc(m);
     end;
    for i:=1 to m do
      Begin
       k:=n div a[i];
       ans:=ans+k;
      end;
     exit(ans);
  end;
 procedure writef(x:longint);
 var i:longint;
 begin
  for i:=x to x+4 do
   write(i,' ');
 end;

 begin
  read(n);
  l:=1;
  r:=1000000;
 // writeln(check());
   while l<r-1 do
    begin
     m:=(l+r) div 2;
      if check(m)<n then l:=m
      else r:=m;
    end;
  //  writeln(check(r),' ',check(l));
    if check(r)=n then begin
             writeln(5);
             writef(r);
             end
    else if check(l)=n then begin
            writeln(5);
            writef(l);
            end
    else write(0);
   end.

const   fi='';
        fo='';

var     m:longint;

Procedure Process;
var     i,j,k,tmp:longint;
begin
        i:=1;   k:=1;
        while k<m do begin
                inc(i);
                inc(k);
                tmp:=i;
                while tmp mod 5 = 0 do begin
                        inc(k);
                        tmp:=tmp div 5;
                end;
        end;
        if k<>m then
                writeln(0)
        else    begin
                writeln(5);
                for j:=i*5 to i*5+4 do
                        write(j,' ');
        end;
end;

BEGIN
        assign(input,fi);       reset(input);
        assign(output,fo);      rewrite(output);

        Readln(m);
        Process;

        close(input);           close(output);
END.

var i,k,m,s:int64;
begin
   read(m);
   s:=0;i:=0;
   While s<m do
   begin
      i:=i+5;k:=i;
      While k mod 5=0 do
      begin
         inc(s);k:=k div 5;
      end;
   end;
   If s = m then
   begin
      writeln(5);
      write(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4)
   end else write(0)
end.

    {$APPTYPE CONSOLE}
const nn=3; besk=2000000000000000000;
   nnn=2000000;  eps=1e-11; modul=1000000007;
 type matr=array[1..3,1..3] of extended;
   mat=^matr;
 label 1,2,3,4;

var i1,j1,k,step,kt,ppp,mask,i0,j0,i,j,start,finish:longint;
newdl,dloch,kol,shag,m,t,ii,jj,l,r,p,p3,pos,ll,bb,pp,tt,ot1,ot2,s,kold,n:int64;
def,xx,cc,q,t1,t2,p4,p1,p2,ot,dist1,vt,zap,ba,by,aa,ay,kk,centr,koef:int64;
flag2,flag1,flag:boolean;
ch1,ch2,ch:char;
str:array[-10..12000] of matr;
prob,ccc1,v,rr,h1,h2,h,r1,r2,aaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;
x,y,invfact,next,prev,x1,x2,y1,y2,d,och,newoch,f,fact,c,b,a,prost:array[-100000..1100000] of int64;
oldzan,oldmarked,zan: array[0..330006] of boolean;
gr:array[-1..1001,-1..1001] of boolean;
agor,aver,ssumgor,ssumver,sgor,sver,udd,dostl,dostr: array[-100..600,-100..600] of int64;
det,ott :double;
d3,d1,d2,dist,edin:matr;
ss,ss1,ss2:string;
dd:array[-21..2001,-2001..2001] of int64;
marked,dost,newdost:array[-10..700000] of boolean;
ssnew:array[-10..1000000] of char;
pole:array[-10..610,-10..600] of char;
name:array[0..2000] of string;
function min (a,b:int64):int64;begin min:=b;if a<b then min:=a;  end;
function max (a,b:int64):int64;begin max:=b;if a>b then max:=a;  end;

 function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function degg(p,deg:int64):int64; var pp,q:int64;
 begin if deg=0 then degg:=1 else begin   if odd(deg) then degg:=(degg(p,deg-1)*p) mod modul else
 begin q:=(degg(p,deg shr 1)) mod modul; degg:=(q*q) mod modul;   end; end;   end;

function kolnul(t:longint):longint; var i,j,ot:longint;
begin
 ot:=0;
 while t>0 do
    begin
     t:=t div 5;
     ot:=ot+t;
   end;
  kolnul:=ot;
 end;

begin
  {assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
    read(n);
     for i:=1 to 1000000 do if kolnul(i)=n then
     begin inc(p); a[p]:=i;  end;

  writeln(p); for i:=1 to p do write(a[i],' ');

   1:          close(output);
end.

program ProjectD;

{$APPTYPE CONSOLE}

uses
  SysUtils,math;
var a,b,c,d,x,y,res:int64;  i:integer;
begin
 // reset(input,'input.txt');
 // rewrite(output,'output.txt');
  read(a);
  b:=0;
  i:=2;
  while 1=1 do
    begin
      if i mod 5 = 0
      then begin
             d:=i;
             while d mod 5 = 0 do
             begin
              inc(b);
              d:=d div 5;
             end;
           end;
      if b>a
      then begin
            write(0);
            halt(0);
           end;
      if b=a
      then begin
             writeln(5);
             write(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4);
             halt(0);
           end;

      inc(i);
    end;
  write(b);
end.

Var
  m:array[1..1000000]of longint;
  n,tk,z,ans:int64;i:longint;
begin
//  assign(input,'input.txt');assign(output,'output.txt');
  readln(n);
  tk:=1;
  m[1]:=0;
  while m[tk]<=n do
    begin
      inc(tk);
      m[tk]:=m[tk-1];
      z:=tk;
      while z mod 5=0 do
        begin
          inc(m[tk]);
          z:=z div 5;
        end;
    end;
  ans:=0;
  for i:=1 to tk do
    if m[i]=n then
      inc(ans);
  writeln(ans);
  for i:=1 to tk do
    if m[i]=n then
      write(i,' ');
end.

{$mode objfpc}

uses math;
var
	fi, fo: text;
	f, t, i, top, tmp, m: integer;
	s: array[0..round(1e5+1)] of integer;

begin
	assign(fi, ''); reset(fi);
	assign(fo, ''); rewrite(fo);
	readln(fi, m);
	f := 0; t := 0;
	i := 1;
	for i := 1 to 5*round(1e5) do begin
		tmp := i;
		while tmp mod 2 = 0 do begin
			inc(t);
			tmp := tmp div 2;
		end;

		while tmp mod 5 = 0 do begin
			inc(f);
			tmp := tmp div 5;
		end;

		if min(f, t) = m then begin
			inc(top);
			s[top] := i;
		end;
	end;
	//writeln(f, ' ', t);
	writeln(top);
	for i := 1 to top do
		write(s[i], ' ');
	writeln;
	close(fi); close(fo);
end.

{$mode objfpc}

uses math;
var
	fi, fo: text;
	f, t, i, top, tmp, m: integer;
	s: array[0..round(1e5+1)] of integer;

begin
	assign(fi, ''); reset(fi);
	assign(fo, ''); rewrite(fo);
	readln(fi, m);
	f := 0; t := 0;
	i := 1;
	for i := 1 to round(1e6) do begin
		tmp := i;
		while tmp mod 2 = 0 do begin
			inc(t);
			tmp := tmp div 2;
		end;

		while tmp mod 5 = 0 do begin
			inc(f);
			tmp := tmp div 5;
		end;

		if min(f, t) = m then begin
			inc(top);
			s[top] := i;
		end;
	end;
	//writeln(f, ' ', t);
	writeln(top);
	for i := 1 to top do
		write(s[i], ' ');
	writeln;
	close(fi); close(fo);
end.

const mx : longint = 500000;

var m, i, j : longint;
    a : array[1..100000] of longint;

function cal(x : longint) : longint;
var cnt, i : longint;

begin
    i := 5; cnt := 0;
    while (x >= i) do
    begin
        cnt := cnt + (x div i);
        i := i * 5;
    end;
    cal := cnt;
end;

begin
    readln(m);
    j := 1;
    for i := 1 to mx do
    begin
        if (cal(i) = m) then
        begin
            a[j] := i;
            inc(j);
        end;
    end;
    writeln(j - 1);
    for i := 1 to j - 1 do write(a[i], ' ');
    writeln;
end.

const fi='';
      fo='';
      max=100000;
var num:extended;
    n,ans,j:longint;
    so:array[1..100] of longint;

procedure doc;
var f:text;
begin
  assign(f,fi);
  reset(f);
  readln(f,n);
  close(f);
  ans:=0;
end;

procedure xl;
var s:ansistring;  f:text;
    i,tmp1,tmp2,x:longint;
begin
  assign(f,fo);
  rewrite(f);
  j:=0;
  x:=0;
  repeat
    x:=x+5;
    str(x,s);
    if (s[length(s)]='5') or (s[length(s)]='0') then begin
      tmp1:=x;
      tmp2:=0;
      while (tmp2=0) do begin
        tmp1:=tmp1 div 5;
        tmp2:=tmp1 mod 5;
        inc(ans);
        end;
      end;
    if ans=n then
      for i:=0 to 4 do begin
        inc(j);
        so[j]:=x+i;
        end;
    until ans>n;
  writeln(f,j);
  for i:=1 to j do write(f,so[i],' ');
  close(f);
end;

begin
  doc;
  xl;
end.

uses math;
var i,j,k,ans:longint;
   d,a:array[0..10000000] of longint;
   m:longint;
   begin
    read(m);

    i:=1;

    while (i*5<=1000000) do
     begin
      inc(j);
      a[j]:=i*5;
      i:=i*5;
     end;

    for i:=1 to 1000000 do
    for k:=1 to j do
    inc(d[i],i div a[k]);

    for i:=1 to 1000000 do
     if d[i]=m then inc(ans);

     writeln(ans);

     for i:=1 to 1000000 do
      if d[i]=m then write(i,' ');
   end.

var
  f,g:text;
  a:array[1..5000000] of longint;
  s,k,i,n:longint;
   begin
     assign(f,'');
     reset(F);assign(g,'');
     rewrite(g);
     readln(F,n);
     k:=5;
     while s<n do
      begin
            if  (k mod 5=0) then begin
               a[k]:=a[k div 5 ]+1;
               s:=s+a[k];
            end;
            if (s=n) then begin
            writeln(g,5);
                  for i:=1 to 5 do
                   begin
                         write(g,k+i-1,' ');
                   end;

            end;
            inc(k);

      end;
      if s<>n then writeln(g,0);
close(f);
close(g);
end.

program Trivial;
label 99;
var m,five:longint;
    n,j,d0,d1,d2,d3,d4,d5,d6,d7,d8:integer;

begin
five:=0;
read(m);
n:=0;

for d0:=1 to 5 do begin
    for d1:=1 to 5 do begin
        for d2:=1 to 5 do begin
            for d3:=1 to 5 do begin
                for d4:=1 to 5 do begin
                    for d5:=1 to 5 do begin
                        for d6:=1 to 5 do begin
                            for d7:=1 to 5 do begin
                                if five >= m then goto 99 ;
                                five:=five+1;
                                n:=n+5;
                            end;
                            five:=five+1;
                        end;
                        five:=five+1;
                    end;
                    five:=five+1;
                end;
                five:=five+1;
            end;
            five:=five+1;
        end;
        five:=five+1;
    end;
    five:=five+1;
end;
99:
if five = m then begin
    writeln('5');
    for j:=0 to 4 do begin
        write((n+j),' ');
    end;
end
else write('0');

end.

var i, n, m, k, o, p, ans:LongInt;
    A:ARRAY [1..100000] of LongInt;
Begin
  Read(n);
  for i:=1 to 400010 do
   Begin
     o:=i;
     k:=0;
    while o>0 do
     Begin
      k:=k+o div 5;
      o:=o div 5;
    End;
    if k=n then Begin inc(ans);A[ans]:=i;End;
 End;
 WriteLn(ans);
 for i:=1 to ans do
  Write(A[i],' ');
End.

var
n,m,k,l,i:longint;
begin
read(n);
  for i:=1 to 10000000 do begin
    l:=i;
    while l>=5 do begin
    if l mod 5 <>0 then break;
    inc(k);
    l:=l div 5;
    end;
    if k=n then begin
    writeln(5);
    for m:=0 to 4 do write(i+m, ' ');
    halt; end;
    end;
    write(0);
    end.

var i,k,m,s:int64;
begin
   read(m);
   s:=0;
   i:=0;
   while s<m do begin
      i:=i+5;
      k:=i;
      while k mod 5=0 do begin
         inc(s);
         k:=k div 5
      end
   end;
   if s=m then begin
      writeln(5);
      write(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4)
   end else
      write(0)
end.

const size=100000;
var
a,b,c:array[0..size+100] of int64;
   p:int64;
i,n:longint;
begin
  readln(n);
  c[0]:=0;
for i:=1 to size do
        begin
        a[i]:=i*5;
        b[i]:=0;

        while a[i] mod 5=0 do
                begin
                a[i]:=a[i] div 5;
                inc(b[i]);
                end;
        a[i]:=i*5;
        c[i]:=c[i-1]+b[i];
        end;
        {
for i:=1 to  n do
writeln(a[i],'  ',b[i],'  ',c[i]);
}
      p:=0;
  while  n>=c[p] do
        begin
         if n=c[p] then
                begin
                writeln(5);
                for i:=0 to 4 do
                write(p*5+i,' ');
                halt(0);
                end;
         inc(p);
        end;
  writeln(0);
end.

var m,dem,i,k,j:longint;
begin
 readln(m); i:=1;
 while 1 = 1 do
  begin
   k:=i*5;
   while k mod 5 = 0 do
    begin
     k:= k div 5;
     inc(dem);
    end;
   if dem = m then
    begin
     writeln(5);
     for j:=0 to 4 do
      write(5*i+j,' ');
     break;
    end;
   if dem > m then begin write(0); break; end;
   inc(i);
  end;
 readln
end.

program m1;
var
a:array[1..500000] of longint;
k,f,s,i,j,n,m:longint;
begin
read(m);
k:=5;
f:=0;
s:=0;
while(s<m) do
begin
  if (k mod 5=0)then
  begin
    a[k]:=a[k div 5]+1;
    s:=s+a[k];
  end;
  if (s=m)then
  begin
    writeln(5);
    for i:=1 to 5 do
      write(k+i-1,' ');
  end;
  k:=k+1;
end;
if (s<>m) then
  write(0);
end.

  Uses MATH;
  var m , n : LongInt;
       i : LongInt;
       Two , Five : LongInt;
       AnsCount : LongInt;
       Ans : Array [ 1 .. 10000000 ] of LongInt;
begin
  readLn ( m ) ;
  Two := 0 ;
  Five := 0 ;
  AnsCount := 0 ;
  i := 1 ;

  while (True ) do
  begin
    n := i ;

    while ( n > 1 ) and ( n mod 2 = 0 ) do
    begin
      inc ( Two ) ;
      n := n div 2;
    end;

    while ( n > 1 ) and ( n mod 5 = 0 ) do
    begin
      inc ( Five ) ;
      n := n div 5;
    end;

    if ( Min ( Two , Five ) = m ) then
    begin
      inc ( AnsCount ) ;
      Ans [ AnsCount ] := i;
    end
    else if ( Min ( Two , Five ) > m ) then
      break;

    i := i + 1 ;
  end;

  writeLn ( AnsCount ) ;
  for i := 1 to AnsCount do
    write ( Ans [ i ] , ' ' ) ;
end.

var
m,q,b,i,j,k:longint;
begin
readln(m);
while(j<m) do begin
inc(i);
k:=i*5;
while(k mod 5=0) do begin
inc(j);
k:=k div 5;
end;
end;
if j=m
then begin
writeln(5);
for j:=0 to 4 do
write(((i*5)+j),' ');
end
else writeln(0);
end.

program z_633_b;
var m,n,k,i,t,f,c,c1,ans,ans2:integer;

begin
readln(m);

while (f<m) do //or(t<m) do
begin
inc(c);
c1:=c;

//while c1 mod 2 = 0 do
//begin
//inc(t);
//c1:=c1 div 2;
//end;

while c1 mod 5 = 0 do
begin
inc(f);
c1:=c1 div 5;
end;

end;

ans:=c;

if (f<>m) then ans:=0 else ans:=5;
writeln(ans);
if ans<>0 then
for i:=c to c+4 do
write(i,' ');

end.

uses math;
var
  n,anskil:longint;
  ans,dop:ansistring;
  i,idop,pot2,pot5:longint;
begin
  read(n);

  i:=1;
  while i<>-1 do
    begin
      idop:=i;
      while idop mod 2=0 do
        begin
          inc(pot2);
          idop:=idop div 2;
        end;
      while idop mod 5=0 do
        begin
          inc(pot5);
          idop:=idop div 5;
        end;
      if min(pot2,pot5)=n then
        begin
          inc(anskil);
          str(i,dop);
          if ans<>'' then ans:=ans+' '+dop
          else ans:=ans+dop;
        end;
      if min(pot2,pot5)>n then break;
      inc(i);
    end;

  writeln(anskil);
  writeln(ans);
end.

//CF633B
const
  five = 5; maxN = trunc(1e3 + 7);
type
  tlist = array[0..maxN] of longint;
var
  p, sum, base, n, top, i: longint;
  stack: tlist;

begin
  //assign(input, 'CF633B.iNP'); reset(input);
  //assign(output, 'CF633B.oUT'); rewrite(output);
  readln(n);
  for i:= 5 to maxlongint do
        begin
          base:= 1; sum:= 0;
          while base <= i do
                begin
                  base:= base * five;
                  inc(sum, i div base);
                end;
          if sum = n then
                begin
                  inc(top); stack[top]:= i;
                end;
          if sum > n then break;
        end;
  writeln(top);
  for i:= 1 to top do write(stack[i], ' ');
  //close(input); close(output);
end.

var n,i,j,d:longint;
    a,b:array[0..10000000] of longint;
begin
 read(n);
 for i:=1 to 200001 do
  begin
    j:=i*5;
    b[i]:=j;
    a[i]:=a[i-1];
    while (j mod 5=0) do
     begin
      inc(a[i]);
      j:=j div 5;
     end;
  end;

  for i:=1 to 1000000 do
   if n=a[i] then
       begin
        writeln(b[i+1]-b[i]);
        for j:=b[i] to b[i+1]-1 do
         write(j,' ');
         break;
       end
   else
    if n<a[i] then
     begin
       write('0');
       break;
    end;

end.

var m,res:longint;
a:array[1..1000000] of longint;
function cal(n:int64):longint;
var kq:longint;
begin
        kq:=0;
        while n>0 do
         begin
               n:=n div 5;
               kq:=kq+n;
         end;
        exit(kq);
end;
procedure progress;
var l,r,mid,t,kq:int64;
i:longint;
begin
        readln(m);
        l:=1; r:=trunc(1e9);
        kq:=0;
        while l<=r do
         begin
              mid:=(l+r) div 2;
              t:=cal(mid);
              if t>=m then
               begin
                   kq:=mid;
                   r:=mid-1;
               end
              else l:=mid+1;
         end;
        while cal(kq)=m do
         begin
              inc(res);
              a[res]:=kq;
              inc(kq);
         end;
        writeln(res);
        for i:=1 to res do write(a[i], ' ');
end;
begin
        progress;

end.

var x,left,rait,midl, otvet:integer;
function suka (x:integer):integer;
var a,b:integer;
begin
        a:=5; b:=0;
        while x/a>=1 do
            begin
              b:=b+trunc(x/a);
              a:=a*5;
            end;
        suka:=b;
        end;
begin
  read(x);  left:=1; rait:=5*x+4;
while (suka(midl)<>x) and(rait-Left>1) do
begin
    midl:=trunc((left+rait)/2);
      if suka(midl)>x then rait:=midl;
      if suka(midl)<x then left:=midl;

end;

if suka(midl)<>x then writeln(0) else
 begin
   writeln(5);
   write(midl - (midl mod 5),' ' ,midl - (midl mod 5)+1,' ',midl - (midl mod 5) +2,' ',midl-(midl mod 5)+3,' ',midl - (midl mod 5)+4);
   end;
   end.

var i:longint;
    x,n,j,k:int64;
    b:array[1..10]of  int64;
begin
read(n);
x:=1;
i:=1;
while k<=n do
   begin
   x:=(x*i) mod 1000000000;
   while x mod 10 =0 do
      begin
      inc(k);
      x:=x div 10;
      end;
   if k=n then
      begin
      inc(j);
      b[j]:=i;
      end;
   inc(i);
   end;
writeln(j);
for i:=1 to j do
   write(b[i],' ');
end.

program p633b;
var
m,j,k:longint;
i:integer;
const five:byte=5;

procedure output(k: longint);
var i:longint;
begin
    writeln(five);
    for i:=0 to 4 do
        write(k*five+i,' ')
end;

begin
readln(m);
j:=0; i:=0;

while(j<m) do
    begin
    i:=i+1;
    k:=i*five;
    while(k mod five = 0) do
        begin
        j:=j+1;
        k:=k div five;
        end;
    end;
if j=m then output(k)
    else writeln(0)
end.

program p633b;
var
m,j,k:longint;
i:integer;
const five:byte=5;

procedure output(k: longint);
var i:longint;
begin
    writeln(five);
    for i:=0 to 4 do
        write(k*five+i,' ')
end;

begin
readln(m);
j:=0; i:=0;

while(j<m) do
    begin
    i:=i+1;
    k:=i*five;
    while(k mod five = 0) do
        begin
        j:=j+1;
        k:=k div five;
        end;
    end;
if j=m then output(j)
    else writeln(0)
end.

const fi = '';
      fo = '';
var i, j, a, m, so, n: longint;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);

  so:=0;  m:=0;
  readln(n);
  for i:=1 to n do
    begin
      m:=m+5;
      a:=i*5;
      while (a mod 5 = 0) and (a > 0) do
        begin
          inc(so);
          a:=a div 5;
        end;
      if so >= n then break
    end;
  if so >= n then
    begin
      writeln(5);
      writeln(m,' ',m+1,' ',m+2,' ',m+3,' ',m+4);
    end
  else write(0);

  close(input); close(output);
end.

const fi = '';
      fo = '';
var i, j, a, m, so, n: longint;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);

  so:=0;
  readln(n);
  for i:=1 to n do
    begin
      a:=i*5;
      while (a mod 5 = 0) and (a > 0) do
        begin
          inc(so);
          a:=a div 5;
        end;
    end;
  if so >= n then
    if so = n then
      begin
        writeln(5);
        writeln(so*5,' ',so*5+1,' ',so*5+2,' ',so*5+3,' ',so*5+4);
      end
    else write(0);

  close(input); close(output);
end.

Var m,k,i:Longint;
Begin
  Readln(m);
  k:=m Div 2;
  k:=k*10;
  If Odd(m) then
    Inc(k,5);
  Writeln(5);
  For i:=0 to 4 do
    Write(k+i,' ');
End.

var
    m,n,tong,p,i,dem:longint;
    kq:array[0..600000] of longint;
begin
    readln(m);
    n:=0;
    while tong<=m do
    begin
        inc(n);
        p:=n;
        while p>0 do
        begin
            tong:=tong+ord(p mod 5=0);
            p:=p div 5;
        end;
        if tong=m then
        begin
            inc(dem);
            kq[dem]:=n;
        end;
    end;
    writeln(dem);
    for i:=1 to dem do write(kq[i],' ');
end.

{$mode objfpc}
{$macro on}
{$define maicute:= for i := 1 to n do}

uses
  Math;

const
  inp  = '';
  outp = '';
  maxN = round(1e6);

var
  fi, fo : textfile;
  n, m  : Integer;
  a, b, s : array[0..maxN] of Integer;

Procedure OpenFile;
begin
  Assign(fi, inp); Reset(fi);
  Assign(fo, outp); Rewrite(fo);
end;

Procedure Init;
begin
  fillchar(a, sizeof(a), 0);
  fillchar(b, sizeof(b), 0);
end;

Procedure Enter;
var
  i, j : Integer;
begin
  ReadLn(fi, m);
end;

Procedure Solve;
var
  i, j : Integer;
  res : Integer;
begin
  a[2] := 1;
  for i := 3 to 100000 do
    if i mod 2 = 0 then
      a[i] := a[i-1] + i div 2
    else a[i] := a[i-1];
  b[5] := 1;
  for i := 6 to 100000 do
    if i mod 5 = 0 then
      b[i] := b[i-1] + i div 5
    else b[i] := b[i-1];
  res := 0;
  for i := 1 to 1000000 do
    if min(a[i], b[i]) = m then
      begin
        inc(res);
        s[res] := i;
      end
    else if min(a[i], b[i]) > m then break;
  Writeln(fo, res);
  for i := 1 to res do write(s[i],' ');
end;

Procedure PrintResult;
begin
end;

Procedure Closefile;
begin
  close(fi); close(fo);
end;

Begin
  OpenFile;
  Init;
  Enter;
  Solve;
  Printresult;
  Closefile;
End.

var a:array[0..200000]of longint;n,i,k,c,b:longint;
begin
read(n);
k:=5;a[1]:=5;c:=1;
for i:=2 to n do
begin
k:=k+5;
if (k) mod 25>0 then begin inc(c);a[i]:=k;end else
begin
  b:=k+1;
  while b mod 5=0 do begin inc(k); b:=b div 5;end;
end; end;
 if a[n]=0 then write(0) else
 begin
   writeln(5);
   for i:=0 to 4 do
   write(a[n]+i,' ');

 end;
end.

program ex;
var i,j,l,m,n,g:integer;
    k,h:longint;
    a:array[1..100200]of integer;
begin

  read(m);
  for i:=1 to 100200 do
  a[i]:=0;
  j:=1;
  k:=5;
  a[1]:=k;
  while(m>j) do
  begin
    k:=k+5;
    h:=5;
    while(k mod h <>0) do
    h:=h*5;
    h:=h div 5;
    j:=j+ k div h;
    a[j]:=k;
  end;

  if a[m]=0
  then write(0)
  else begin
  writeln(5);
  writeln(a[m],' ',a[m]+1,' ',a[m]+2,' ',a[m]+3,' ',a[m]+4);
  end;

end.

Program Buntarik;
uses math;
var x,i,kol,k,ans,n:longint;
a:array[0..100000] of longint;

begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }

readln(n);  k:=0;
for i:=1 to 100000 do
 begin
  x:=i; kol:=0;
  while x mod 5=0 do
   begin
   inc(kol);
   x:=x div 5;
   end;
  inc(ans,kol);
  if ans=n
  then begin writeln(5); writeln(i,' ',i+1,' ',i+2,' ',i+3,' ',i+4); halt; end
  else if ans>n then break;
 end;
 writeln(k);

{close(input);   close(output); }
end.

Program Buntarik;
uses math;
var x,i,kol,k,ans,n:longint;
a:array[0..100000] of longint;

begin
{assign(input,'input.txt');
reset(input);
assign(output,'output.txt');
rewrite(output); }

readln(n);
for i:=1 to 100000 do
 begin
  x:=i; kol:=0;
  while x mod 5=0 do
   begin
   inc(kol);
   x:=x div 5;
   end;
  inc(ans,kol);
  if ans=n
  then begin inc(k); a[k]:=i; end
  else if ans>n then break;
 end;
 writeln(k);
 for i:=1  to k do
 write(a[i],' ');

{close(input);   close(output); }
end.

Var a:array[1..12000] of longint;
n,i:longint;
 begin
  read(n);
   if n mod 5 = 0 then begin
                        write(0);
                        halt;
                       end;
                       writeln(5);
   n:=(n-(n div 5))*5;
   for i:=n to n+4 do
    write(i,' ');
                       end.

Var a:array[1..12000] of longint;
n,i:longint;
 begin
  read(n);
 if n=5 then begin
               write(0);
               halt;
             end;
     writeln(5);
   n:=(n-(n div 5))*5;
   for i:=n to n+4 do
    write(i,' ');
                       end.

Var a:array[1..1000] of longint;
n,i:longint;
 begin
  read(n);
   if n mod 5 = 0 then begin
                        write(0);
                        halt;
                       end;
                       writeln(5);
   n:=(n-(n div 5))*5;
   for i:=n to n+4 do
    write(i,' ');
                       end.

Var a:array[1..12000] of longint;
n,i:longint;
 begin
  read(n);
 if n=5 then begin
               write(0);
               halt;
             end;

   n:=(n-(n div 5))*5;
   for i:=n to n+4 do
    write(i,' ');
                       end.

{$mode objfpc}

uses math;
var
	fi, fo: text;
	f, t, i, top, tmp, m: integer;
	s: array[0..round(1e5+1)] of integer;

begin
	assign(fi, ''); reset(fi);
	assign(fo, ''); rewrite(fo);
	readln(fi, m);
	f := 0; t := 0;
	for i := 1 to round(1e5) do begin
		tmp := i;
		while tmp mod 2 = 0 do begin
			inc(t);
			tmp := tmp div 2;
		end;

		while tmp mod 5 = 0 do begin
			inc(f);
			tmp := tmp div 5;
		end;

		if min(f, t) = m then begin
			inc(top);
			s[top] := i;
		end;
	end;
	//writeln(f, ' ', t);
	writeln(top);
	for i := 1 to top do
		write(s[i], ' ');
	writeln;
	close(fi); close(fo);
end.

{$mode objfpc}

uses math;
var
	fi, fo: text;
	f, t, i, top, tmp, m: integer;
	s: array[0..round(1e5+1)] of integer;

begin
	assign(fi, ''); reset(fi);
	assign(fo, ''); rewrite(fo);
	readln(fi, m);
	f := 0; t := 0;
	for i := 1 to 2*round(1e5) do begin
		tmp := i;
		while tmp mod 2 = 0 do begin
			inc(t);
			tmp := tmp div 2;
		end;

		while tmp mod 5 = 0 do begin
			inc(f);
			tmp := tmp div 5;
		end;

		if min(f, t) = m then begin
			inc(top);
			s[top] := i;
		end;
	end;
	//writeln(f, ' ', t);
	writeln(top);
	for i := 1 to top do
		write(s[i], ' ');
	writeln;
	close(fi); close(fo);
end.

{$mode objfpc}

uses math;
var
	fi, fo: text;
	f, t, i, top, m: integer;
	s: array[0..round(1e5+1)] of integer;

begin
	assign(fi, ''); reset(fi);
	assign(fo, ''); rewrite(fo);
	readln(fi, m);
	f := 0; t := 0;
	for i := 1 to round(1e5) do begin
		if i mod 5 = 0 then inc(f, i div 5);
		if i mod 2 = 0 then inc(t, i div 2);
		if min(f, t) = m then begin
			inc(top);
			s[top] := i;
		end;
	end;
	//writeln(f, ' ', t);
	writeln(top);
	for i := 1 to top do
		write(s[i], ' ');
	writeln;
	close(fi); close(fo);
end.

{$mode objfpc}

uses math;
var
	fi, fo: text;
	f, t, i, top, m: integer;
	s: array[0..round(1e5+1)] of integer;

begin
	assign(fi, ''); reset(fi);
	assign(fo, ''); rewrite(fo);
	readln(fi, m);
	f := 0; t := 0;
	for i := 1 to round(1e5) do begin
		if i mod 10 = 5 then inc(f);
		if i mod 10 = 2 then inc(t);
		if i mod 10 = 0 then begin
			inc(t); inc(f);
		end;
		if min(f, t) = m then begin
			inc(top);
			s[top] := i;
		end;
	end;
	//writeln(f, ' ', t);
	writeln(top);
	for i := 1 to top do
		write(s[i], ' ');
	writeln;
	close(fi); close(fo);
end.

const mx : longint = 500000;

var m, i, j : longint;
    a : array[1..100000] of longint;

function cal(x : longint) : longint;
var cnt, i : longint;

begin
    i := 5; cnt := 0;
    while (x >= i) do
    begin
        cnt := cnt + (x div i);
        i := i * 5;
    end;
    cal := cnt;
end;

begin
    readln(m);
    j := 1;
    for i := 1 to mx do
    begin
        if (cal(i) = m) then
        begin
            a[j] := i;
            inc(j);
        end;
    end;
    writeln(j);
    for i := 1 to j do write(a[i], ' ');
    writeln;
end.

var m, i, j : longint;
    a : array[1..100000] of longint;

function cal(x : longint) : longint;
var cnt, i : longint;

begin
    i := 5; cnt := 0;
    while (x >= i) do
    begin
        cnt := cnt + (x div i);
        i := i * 5;
    end;
    cal := cnt;
end;

begin
    readln(m);
    j := 1;
    for i := 1 to m do
    begin
        if (cal(i) = m) then
        begin
            a[j] := i;
            inc(j);
        end;
    end;
    writeln(j);
    for i := 1 to j do write(a[i], ' ');
    writeln;
end.

program Trivial;

var m,five:longint;
    k,n,j:integer;
    a:array[1..10] of integer;

begin
for j:=1 to 10 do begin
    a[j]:=0;
end;
k:=0;
n:=1;
five:=0;
read(m);
while m>=five do begin
    if n mod 5 = 0 then five:=five + (n div 5);
    if five=m then begin
        k:=k+1;
        a[k]:=n;
    end;
    n:=n+1;
end;
writeln(k);
for j:=1 to 10 do begin
    if a[j]<>0 then write(a[j],' ')
    else break;
end;
end.

program Trivial;
label 99;
var m,five:longint;
    n,j,d1,d2,d3,d4,d5,d6,d7:integer;

begin
five:=0;
read(m);
n:=0;

for d1:=1 to 5 do begin
    for d2:=1 to 5 do begin
        for d3:=1 to 5 do begin
            for d4:=1 to 5 do begin
                for d5:=1 to 5 do begin
                    for d6:=1 to 5 do begin
                        for d7:=1 to 5 do begin
                            if five >= m then goto 99 ;
                            five:=five+1;
                            n:=n+5;
                        end;
                        five:=five+1;
                    end;
                    five:=five+1;
                end;
                five:=five+1;
            end;
            five:=five+1;
        end;
        five:=five+1;
    end;
    five:=five+1;
end;
99:
if five = m then begin
    writeln('5');
    for j:=0 to 4 do begin
        write((n+j),' ');
    end;
end
else write('0');

end.

program Trivial;
label 99;
var m,five:longint;
    n,j,d0,d1,d2,d3,d4,d5,d6,d7,d8:integer;

begin
five:=0;
read(m);
n:=0;

for d0:=1 to 5 do begin
    for d1:=1 to 5 do begin
        for d2:=1 to 5 do begin
            for d3:=1 to 5 do begin
                for d4:=1 to 5 do begin
                    for d5:=1 to 5 do begin
                        for d6:=1 to 5 do begin
                            for d7:=1 to 5 do begin
                                if five >= m then goto 99 ;
                                five:=five+1;
                                n:=n+5;
                            end;
                            five:=five+1;
                        end;
                        five:=five+1;
                    end;
                    five:=five+1;
                end;
                five:=five+1;
            end;
            five:=five+1;
        end;
        five:=five+1;
    end;
end;
99:
if five = m then begin
    writeln('5');
    for j:=0 to 4 do begin
        write((n+j),' ');
    end;
end
else write('0');

end.

program Trivial;

var m,five:longint;
    n,j:integer;
function fivpow(num : integer):integer;
var nk:integer;
begin
nk:=-1;
    while num<>0 do begin
        num:=num div 5;
        nk:=nk+1;
    end;
fivpow:=nk;
end;

begin
five:=0;
n:=5;
read(m);

while m >= five do begin
    five:=five+fivpow(n);
    if five=m then begin
        writeln('5');
        for j:=0 to 4 do begin
            write((n+j),' ');
        end;
        break;
    end;
    n:=n+5;

end;
if m<five then write('0')

end.

program Trivial;

var m,five:longint;
    n,j:integer;
function fivpow(num : longint):longint;
var nk:integer;
begin
nk:=-1;
    while num<>0 do begin
        num:=num div 5;
        nk:=nk+1;
    end;
fivpow:=nk;
end;

begin
five:=0;
n:=5;
read(m);

while m >= five do begin
    five:=five+fivpow(n);
    if five=m then begin
        writeln('5');
        for j:=0 to 4 do begin
            write((n+j),' ');
        end;
        break;
    end;
    n:=n+5;

end;
if m<five then write('0')

end.

var
n,m,k,l,i:longint;
begin
read(n);
  for i:=1 to 10000000 do begin
    l:=i;
    while l>=5 do begin
    if l mod 5 <>0 then break;
    inc(k);
    l:=l div 5;
    end;
    if k=n then begin
    for m:=0 to 4 do write(i+m, ' ');
    halt; end;
    end;
    write(0);
    end.

var
n,m,k,l,i:longint;
begin
read(n);
  m:=5;
  l:=0;
  k:=0;
  while m<n do       begin     inc(l);k:=k+l;  m:=m*5; end;
  m:=1;
  for i:=1 to 12 do begin m:=m*5; if n=m then begin write(0); halt; end;
  end;
  writeln(5);
  for i:=0 to 4 do write(n*5-k*5+i, ' ');
  end.

var
n,m,k,l,i:longint;
begin
read(n);
  m:=5;
  l:=0;
  k:=0;
  while m<n do       begin     inc(l);k:=k+l;  m:=m*5; end;
  m:=1;
  for i:=1 to 12 do begin m:=m*5; if n=m then begin write(0); halt; end;
  end;
  writeln(5);
  for i:=0 to 4 do write(n*5-k*5+l*5+i, ' ');
  end.

var m,dem,j,i:longint;
    a:array[0..5*100000] of int64;
begin
 readln(m); dem:=0; j:=0;
 if m = 5 then begin write(0); exit; end;
 for i:=0 to 5*100000 do
  begin
   inc(j);
   a[i]:=dem;
   if j = 5 then begin inc(dem); j:=0; end;
   if dem = 5 then inc(dem);
  end;
 writeln(5);
 for i:=0 to 4 do
  write(m*5+i,' ');
 readln
end.

var m,dem,j,i,t:longint;
    a:array[0..5*100000] of int64;
begin
 readln(m); dem:=0; j:=0; t:=5;
 while m >= t do
  begin
   if m = t then begin write(0); exit; end;
   t:=t + 6;
  end;
 t:=-1;
 for i:=0 to 5*100000 do
  begin
   inc(j);
   a[i]:=dem;
   if j = 5 then begin inc(dem); j:=0; end;
   if dem = t + 6  then begin t:=t + 6; inc(dem); end;
  end;
 writeln(5);
 for i:=0 to 5*100000 do
  if m = a[i] then write(i,' ');
 readln
end.

program m1;
var
i,j,n,m:longint;
begin
read(m);
writeln(5);
for i:=1 to 5 do
write(5*m-1+i,' ');
end.

const
 fi='';
 fo='';
type arr=array[1..1000000] of longint;
var d:arr; f:text;m:longint;
procedure xl;
var max,i,k,d,t,du,tam:longint;
begin
 assign(f,fi);
 reset(f);
 readln(f,m);
 close(f);
 d:=0;
 t:=0;
 max:=0;
 while max<=m do
  begin
   inc(t);
   k:=t;
   d:=0;
   while k div 5>0 do
        begin
        if k mod 5=0 then inc(d);
         k:=k div 5;
        end;
   if (t mod 5=0) then max:=max+d;
   if max=m then break;
  end;
 assign(f,fo);
 rewrite(f);
 if max>m then write(f,'0') else
 begin
  writeln(f,'5');
 for i:=0 to 4 do write(f,t+i,' ');
 end;
 close(f);
end;
begin
 xl;
end.

const
 fi='';
 fo='';
type arr=array[1..1000000] of longint;
var d:arr; f:text;m:longint;
procedure xl;
var max,i,k,d,t,du,tam:longint;
begin
 assign(f,fi);
 reset(f);
 readln(f,m);
 close(f);
 d:=0;
 t:=0;
 max:=0;
 while max<=m do
  begin
   inc(t);
   k:=t;
   d:=0;
   while k div 5>0 do
        begin
         inc(d);
         k:=k div 5;
        end;
   if (t mod 5=0) then max:=max+d;
   if max=m then break;
  end;
 assign(f,fo);
 rewrite(f);
 if max>m then write(f,'0') else
 begin
  writeln(f,'5');
 for i:=0 to 4 do write(f,t+i,' ');
 end;
 close(f);
end;
begin
 xl;
end.

const
 fi='';
 fo='';
type arr=array[1..1000000] of longint;
var d:arr; f:text;m:longint;
procedure xl;
var max,i,k,d,t,du,tam:longint;
begin
 assign(f,fi);
 reset(f);
 readln(f,m);
 close(f);
 d:=0;
 t:=0;
 max:=0;
 while max<=m do
  begin
   inc(t);
   k:=t;
   d:=0;
   while k div 5>0 do
        begin
         inc(d);
         k:=k div 5;
        end;
   tam:=k;
   for i:=1 to d do tam:=tam*5;
   if (tam=t) then max:=max+d;
   if max=m then break;
  end;
 assign(f,fo);
 rewrite(f);
 if max>m then write(f,'0') else
 begin
  writeln(f,'5');
 for i:=0 to 4 do write(f,t+i,' ');
 end;
 close(f);
end;
begin
 xl;
end.

const fi='';
      fo='';
      max=100000;
var num:extended;
    n,ans,j:longint;
    so:array[1..100] of longint;

procedure doc;
var f:text;
begin
  assign(f,fi);
  reset(f);
  readln(f,n);
  close(f);
  ans:=0;
end;

procedure xl;
var s:ansistring;  f:text;
    i,tmp1,tmp2:longint;
begin
  assign(f,fo);
  rewrite(f);
  j:=0;
  for i:=1 to max do begin
    str(i,s);
    if (s[length(s)]='5') or (s[length(s)]='0') then begin
      tmp1:=i;
      tmp2:=0;
      while (tmp2=0) do begin
        tmp1:=tmp1 div 5;
        tmp2:=tmp1 mod 5;
        inc(ans);
        end;
      end;
    if ans=n then begin
      inc(j);
      so[j]:=i;
      end;
    if ans>n then break;
    end;
  writeln(f,j);
  for i:=1 to j do write(f,so[i],' ');
  close(f);
end;

begin
  doc;
  xl;
end.

program z_633_b;
var m,n,k,i:integer;
s,f:int64;

function st(a,n:integer):int64;
begin
if n mod 2 = 1 then
begin
if n=1 then st:=a
else st:=st(a,n-1)*a;
end;
if n mod 2 = 0 then
begin
if n=2 then st:=sqr(a)
else st:=st(sqr(a),n div 2);
end;
end;

function fact(n:integer):int64;
begin
if n=1 then fact:=n
else fact:=fact(n-1)*n;
end;

begin
readln(m);
s:=st(10,m);

for i:=5*m to 5*m+4 do
begin
f:=fact(i);

if f mod s = 0 then
begin
inc(k);
//write(i,' ');
end;

end;

writeln(k);

for i:=5*m to 5*m+4 do
begin
f:=fact(i);

if f mod s = 0 then
begin
//inc(k);
write(i,' ');
end;

end;

end.

program z_633_b;
var m,n,k,i,t,f,c,c1,ans,ans2:integer;

begin
readln(m);

while (f<m) do
begin
inc(c);
c1:=c;

while c1 mod 5 = 0 do
begin
inc(f);
c1:=c1 div 5;
end;

end;

ans:=c;

writeln(ans);
if ans<>0 then
for i:=c to c+4 do
write(i,' ');

end.

var n,i,j,d:longint;
    a,b:array[0..100000] of longint;
begin
 read(n);
 for i:=1 to 20001 do
  begin
    j:=i*5;
    b[i]:=j;
    a[i]:=a[i-1];
    while (j mod 5=0) do
     begin
      inc(a[i]);
      j:=j div 5;
     end;
  end;

  for i:=1 to 20001 do
   if n=a[i] then
       begin
        writeln(b[i+1]-b[i]);
        for j:=b[i] to b[i+1]-1 do
         write(j,' ');
         break;
       end
   else
    if n<a[i] then
     begin
       write('0');
       break;
    end;

end.

var n,i,j,d:longint;
    a,b:array[0..100000] of longint;
begin
 read(n);
 for i:=1 to 20000 do
  begin
    j:=i*5;
    b[i]:=j;
    a[i]:=a[i-1];
    while (j mod 5=0) do
     begin
      inc(a[i]);
      j:=j div 5;
     end;
  end;

  for i:=1 to 20000 do
   if n=i then
     if a[i+1]-a[i]=1 then
       begin
        writeln(b[i+1]-b[i]);
        for j:=b[i] to b[i+1]-1 do
         write(j,' ');
         break;
       end
     else
       begin
        write('0');
         break;
       end
   else
    begin
     write('0');
     break;
    end;

end.

var m,res:longint;
a:array[1..1000000] of longint;
function cal(n:int64):longint;
var kq:longint;
begin
        kq:=0;
        while n>0 do
         begin
               n:=n div 5;
               kq:=kq+n;
         end;
        exit(kq);
end;
procedure progress;
var l,r,mid,t,kq:int64;
i:longint;
begin
        readln(m);
        l:=1; r:=9;
        kq:=0;
        while l<=r do
         begin
              mid:=(l+r) div 2;
              t:=cal(mid);
              if t>=m then
               begin
                   kq:=mid;
                   r:=mid-1;
               end
              else l:=mid+1;
         end;
        while cal(kq)=m do
         begin
              inc(res);
              a[res]:=kq;
              inc(kq);
         end;
        writeln(res);
        for i:=1 to res do write(a[i], ' ');
end;
begin
        progress;

end.


var n,i,h,k,j:longint; p,q,ans:extended; l,r:array[0..5]of longint;

function max(a1,a2:longint):longint;
begin
  if a1>a2 then exit(a1) else exit(a2);
end;

function min(a1,a2:longint):longint;
begin
  if a1>a2 then exit(a2) else exit(a1);
end;

begin
  readln(n);
  for i:=1 to n do readln(l[i],r[i]);
  for i:=1 to 10000 do
  begin
    for j:=1 to n do
    if (i>=l[j]) and (i<=r[j]) then
    begin
      p:=i/(r[j]-l[j]+1);
      for k:=1 to n do
      if k<>j then
      begin
        q:=p*max(r[k]-max(l[k],i+1)+1,0)/(r[k]-l[k]+1);
        for h:=1 to n do
        if (h<>k) and (h<>j) then
          if h>j then q:=q*max(min(i,r[h])-l[h]+1,0)/(r[h]-l[h]+1) else q:=q*max(min(i-1,r[h])-l[h]+1,0)/(r[h]-l[h]+1);
        ans:=ans+q;
      end;
      for k:=j+1 to n do
      if (i>=l[k]) and (i<=r[k]) then
      begin
        q:=p/(r[k]-l[k]+1);
        for h:=1 to n do
        if (h<>k) and (h<>j) then
          if h>k then q:=q*max(min(i,r[h])-l[h]+1,0)/(r[h]-l[h]+1) else q:=q*max(min(i-1,r[h])-l[h]+1,0)/(r[h]-l[h]+1);
        ans:=ans+q;
      end;
    end;
  end;
  writeln(ans:0:10);
end.

  const  eps=1e-11;  besk=200000000000000008;
   label 1,2,3,4;
    type
    mas=array [-10000..300000] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10000..200000] of int64;mass1=^mas;
    var iii,q1,q2,t0,bb,cc,dd,p1old,p2old,p13,r,l,p1,p2,aaa,bbb,t,sum1,dist,modul,n,m,poz,sum,p3,p4,t4,t5,t6,t1,t2,t3,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,kk,qq,ot,kol,nn,x0,y0,s1,s2,s,imax,smin,dl,besk1:int64;
    start,shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;
     sssnew:array[-10..10000] of char;
    poin:zap;     edin:mas;
    vec:array[-100..1000] of zap;
   aa,dp, maskk,d,plb,plc,c,aold,anew,b1,fact, a1,bl,br,a,b:mas;
    pole1, pole:array[-1..3000,-100..3000] of char;
    ss, ss1,ss2:string;
   ch3, ch1,ch2:char;
   ver:array[-10..100000] of extended;
    gr:array[-1..1002,-1..1002] of int64;
    ssn,sss:array[-100..1000000] of string;
    ch: char;
    zan,marked:array[-10..1000000] of boolean;
    maxpr:array[0..100000] of string;
     hh,beta,pr,aanew,v0,v1,s0:extended;
     lx,ly,rx,ry,z,x1,y1,y,x:array[-1..300000] of int64;
    xm,xn, xxx,yyy:array[-1..100000] of double;
    ugol,per,pp2, ee,yot:extended;
       flagg,flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p;
 end;

  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;
    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function degg(a:int64;k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul  else
   begin  p:=degg(a,k div 2); degg:=(p*p) mod modul;    end;

end;

function koled(p:int64):int64; var t,ot:int64;
 begin
   ot:=0; t:=p; while t>0 do begin ot:=ot+t and 1; t:=t shr 1;  end;
   koled:=ot;
 end;

function vergr(ii,gg:int64):extended;    var ppp:extended;
begin   {writeln(b[ii],'  ',a[ii],'   ==  ii=  ',ii); }
 if gg>b[ii]then ppp:=0 else if gg<=a[ii]
 then ppp:=1 else ppp:=(b[ii]-gg+1)/(b[ii]-a[ii]+1);
 vergr:=ppp;
  end;

  begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }

     read(n); for i:=1 to n do read(a[i],b[i]);
     p:=1;
    { for i:=0 to 32 do writeln(i,' ',koled(i));
    } for i:=1 to n do p:=p*2;
     for mask:=0 to p-1 do if koled(mask)>=2 then
      begin
          p:=mask;
          for i:=1 to n do begin aa[i]:=p and 1; p:=p shr 1; end;
         { for i:=1 to n do write(aa[i],' '); writeln;
       } for k:=0 to 20001 do
        begin
          hh:=1;
          for i:=1 to n do if aa[i]=1 then hh:=hh*vergr(i,k) else hh:=hh*(1-vergr(i,k));
      {  writeln(k,'  hh= ',hh:0:4);  }
        ver[k]:=ver[k]+hh;
        end;
      end;
   { for i:=1 to 3 do for j:=0 to 10 do writeln(i,' ',j,' ',vergr(i,j):0:4); writeln;
    for k:=0 to 10 do writeln(k,' == ',ver[k]:0:4);
  } for k:=0 to 20001 do yot:=yot+k*(ver[k]-ver[k+1]);
    writeln(yot:0:9);

     1:          close(output);
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of extended;
    re:array[0..10001]of extended;
    rr:array[0..10001,0..30] of longint;
    res,tot,mm:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>c)or((qq[j]=c)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  //for i:=1 to 10000 do
   // for k:=0 to 18 do
     // begin
     // rr[i,k]:=r[i] mod 10;
     // r[i]:=r[i] div 10;
     // end;
  for i:=1 to 10000 do re[i]:=r[i];
  q:=1;
  c:=10000;
  {while c-q>1 do
    begin
    while re[q]<0.5 do inc(q);
    while re[c]<0.5 do dec(c);
    if (q+c) mod 2 = 0 then
      begin
      if re[q]<re[c] then mm:=re[q] else mm:=re[c];
      re[(q+c) div 2]:=re[(q+c) div 2]+mm+mm;
      re[q]:=re[q]-mm;
      re[c]:=re[c]-mm;
      end
    else
      begin
      if re[q]<re[c] then mm:=re[q] else mm:=re[c];
      re[(q+c)div 2]:=re[(q+c)div 2]+mm;
      re[(q+c)div 2+1]:=re[(q+c)div 2+1]+mm;
      re[q]:=re[q]-mm;
      re[c]:=re[c]-mm;
      end;
    end;
  res:=0.0;   {}
  for c:=1 to 10000 do res:=res+r[c]*c;
  res:=res/tot;
  writeln(res:0:20);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

var n,i,j,k,l,x2,m1,m : longint;
    a : array[1..5,1..2] of longint;
  //  p : array[1..10000] of extended;
    p : array[1..5,1..3] of extended;
    avg,prob : extended;

function sec(x,y,z,z1,z2 : longint) : longint;
var  a : array[1..5] of longint;
     i,j,buf : longint;
  begin
    a[1] := x;
    a[2] := y;
    a[3] := z;
    a[4] := z1;
    a[5] := z2;
    for i := 1 to 5 do
      for j := 5 downto 2 do
        if a[j] < a[j-1] then begin
          buf := a[j];
          a[j] := a[j-1];
          a[j-1] := buf;

        end;

    sec := a[2];
  end;
begin

  avg := 0;
  readln(n);

  for i := 1 to n do
    readln(a[i,1],a[i,2]);
  for i := 1 to 10000 do begin
  //  writeln(i,':');
    for j := 1 to n do begin
      x2 := a[j,2]-a[j,1]+1;
      if a[j,1] > i then p[j,1] := 1 else
        if a[j,2] <= i then p[j,1] := 0 else
          p[j,1] := (a[j,2]-i)/x2;

      if (i >= a[j,1]) and (i <= a[j,2]) then p[j,2] := 1/x2 else
      p[j,2] := 0;
       if a[j,1] > i then p[j,3] := 0 else
        if a[j,2] < i then p[j,3] := 1 else
          p[j,3] := (i-a[j,1])/x2;

    end;
  //  for j := 1 to n do begin
  //    writeln(p[j,1]:1:5,' ',p[j,2]:1:5,' ',p[j,3]:1:5,' ',p[j,1]+p[j,2]+p[j,3]:1:5);
 //   end;

    prob := 0;

    if (n = 2) then begin
    for j := 1 to 3 do
      for k := 1 to 3 do

          if sec(j,k,1000000,1000000,1000000) = 2 then
            prob := prob+p[1,j]*p[2,k];
    end;

    if (n = 3) then begin
    for j := 1 to 3 do
      for k := 1 to 3 do
        for l := 1 to 3 do
          if sec(j,k,l,1000000,1000000) = 2 then
            prob := prob+p[1,j]*p[2,k]*p[3,l];
    end;

    if (n = 4) then begin
    for j := 1 to 3 do
      for k := 1 to 3 do
        for l := 1 to 3 do
        for m := 1 to 3 do
          if sec(j,k,l,m,1000000) = 2 then
            prob := prob+p[1,j]*p[2,k]*p[3,l]*p[4,m];
    end;

    if (n = 5) then begin
    for j := 1 to 3 do
      for k := 1 to 3 do
        for l := 1 to 3 do
        for m := 1 to 3 do
        for m1 := 1 to 3 do
          if sec(j,k,l,m,m1) = 2 then
            prob := prob+p[1,j]*p[2,k]*p[3,l]*p[4,m]*p[5,m1];
    end;

    //writeln(prob:1:5);
    //writeln('----');
    avg := avg+prob*i;

  end;

  writeln(avg:1:10);
end.

program problem3;
uses math;

var	n, i, j, k, p: longInt;
	l, r: array[ 1..5 ] of longInt;
	f: array[ 0..5, 0..5 ] of extended;
	ans: extended;

begin
	readln( n );
	for i := 1 to n do
		readln( l[i], r[i] );

	ans := 0.0;
	for i := 1 to n do
		for j := 1 to r[i] do
		begin
			f[0][0] := 1.0;
			for k := 1 to n do
			begin
				if ( k = i ) then
				begin
					move( f[k - 1], f[k], sizeOf( f[k] ) );

					continue;
				end;

				for p := 0 to n do
					f[k][p] := 0.0;

				f[k][0] := f[k - 1][0] * max( min( r[k] + 1, j ) - l[k], 0 ) / ( r[k] - l[k] + 1 );
				if ( l[k] <= j ) and ( j <= r[k] ) then
				begin
					for p := 1 to n do
						f[k][p] := ( f[k - 1][p] * ( j - l[k] ) + f[k - 1][p - 1] ) / ( r[k] - l[k] + 1 )
				end
				else
				begin
					for p := 1 to n do
						f[k][p] := f[k - 1][p] * max( min( r[k] + 1, j ) - l[k], 0 ) / ( r[k] - l[k] + 1 );
				end;
			end;

			for k := 1 to n do
			begin
				ans := ans + f[n][k] * j * ( r[i] - max( j, l[i] - 1 ) ) / ( r[i] - l[i] + 1 );

				if ( j >= l[i] ) then
					ans := ans + f[n][k] * j / ( ( r[i] - l[i] + 1 ) * (k + 1) );
			end;
		end;

	writeln( ans:0:15 );
end.

  const  eps=1e-11;  besk=200000000000000008;
   label 1,2,3,4;
    type
    mas=array [-10000..300000] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[-10000..200000] of int64;mass1=^mas;
    var iii,q1,q2,t0,bb,cc,dd,p1old,p2old,p13,r,l,p1,p2,aaa,bbb,t,sum1,dist,modul,n,m,poz,sum,p3,p4,t4,t5,t6,t1,t2,t3,jj,pold,xx,yy,pp,n2,ost,ll,rr,p,q,tt,n1,h,kk,qq,ot,kol,nn,x0,y0,s1,s2,s,imax,smin,dl,besk1:int64;
    start,shag,imin,ii,k,i1,i2,i3,i4,i5,i6,i7,j1,j2,mask,step,i,j:longint;
     sssnew:array[-10..10000] of char;
    poin:zap;     edin:mas;
    vec:array[-100..1000] of zap;
   aa,dp, maskk,d,plb,plc,c,aold,anew,b1,fact, a1,bl,br,a,b:mas;
    pole1, pole:array[-1..3000,-100..3000] of char;
    ss, ss1,ss2:string;
   ch3, ch1,ch2:char;
   ver:array[-10..100000] of extended;
    gr:array[-1..1002,-1..1002] of int64;
    ssn,sss:array[-100..1000000] of string;
    ch: char;
    zan,marked:array[-10..1000000] of boolean;
    maxpr:array[0..100000] of string;
     hh,beta,pr,aanew,v0,v1,s0:extended;
     lx,ly,rx,ry,z,x1,y1,y,x:array[-1..300000] of int64;
    xm,xn, xxx,yyy:array[-1..100000] of double;
    ugol,per,pp2, ee,yot:extended;
       flagg,flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p;
 end;

  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

  function evkl(a,b:int64):zap1; var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64;
  tt:zap; tt1:zap1;
begin
  if a<b then begin r:=a;a:=b;b:=r; end;
  x2:=1;x1:=0;y2:=0;y1:=1;
  while b>0 do
    begin q:=a div b; r:=a mod b; x:=x2-q*x1;y:=y2-q*y1;
          a:=b;b:=r;x2:=x1;x1:=x;y2:=y1;y1:=y;
    end;
    d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt;
   evkl:=tt1;
end;

function degg(a:int64;k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=(degg(a,k-1)*a) mod modul  else
   begin  p:=degg(a,k div 2); degg:=(p*p) mod modul;    end;

end;

function koled(p:int64):int64; var t,ot:int64;
 begin
   ot:=0; t:=p; while t>0 do begin ot:=ot+t and 1; t:=t shr 1;  end;
   koled:=ot;
 end;

function vergr(ii,gg:int64):extended;    var ppp:extended;
begin   {writeln(b[ii],'  ',a[ii],'   ==  ii=  ',ii); }
 if gg>b[ii]then ppp:=0 else if gg<=a[ii]
 then ppp:=1 else ppp:=(b[ii]-gg+1)/(b[ii]-a[ii]+1);
 vergr:=ppp;
  end;

  begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }

     read(n); for i:=1 to n do read(a[i],b[i]);
     p:=1;
    { for i:=0 to 32 do writeln(i,' ',koled(i));
    } for i:=1 to n do p:=p*2;
     for mask:=0 to p-1 do if koled(mask)>=2 then
      begin
          p:=mask;
          for i:=1 to n do begin aa[i]:=p and 1; p:=p shr 1; end;
         { for i:=1 to n do write(aa[i],' '); writeln;
       } for k:=0 to 10001 do
        begin
          hh:=1;
          for i:=1 to n do if aa[i]=1 then hh:=hh*vergr(i,k) else hh:=hh*(1-vergr(i,k));
      {  writeln(k,'  hh= ',hh:0:4);  }
        ver[k]:=ver[k]+hh;
        end;
      end;
  {  for i:=1 to 3 do for j:=0 to 10 do writeln(i,' ',j,' ',vergr(i,j):0:4);
    for k:=0 to 10 do writeln(k,' == ',ver[k]:0:4);
  } for k:=0 to 10000 do yot:=yot-k*(ver[k]-ver[k-1]);
    writeln(yot-1:0:9);

     1:          close(output);
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    re:array[0..10001]of extended;
    rr:array[0..10001,0..30] of longint;
    res,tot:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  //for i:=1 to 10000 do
   // for k:=0 to 18 do
     // begin
     // rr[i,k]:=r[i] mod 10;
     // r[i]:=r[i] div 10;
     // end;
  for i:=1 to 10000 do re[i]:=r[i]/tot;
  //q:=1;
  //c:=10000;
  //while c-q>1 do
  //  begin
  //
  //  end;
  res:=0.0;
  for c:=1 to 10000 do res:=res+re[c]*c;
  writeln(res:0:20);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    res,tot:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  res:=0.0;
  for c:=1 to 10000 do res:=res+(r[c]+0.0)*c;
  res:=res/tot;
  writeln(res:0:12);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    re:array[0..10001]of extended;
    rr:array[0..10001,0..30] of longint;
    res,tot,mm:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>c)or((qq[j]=c)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  //for i:=1 to 10000 do
   // for k:=0 to 18 do
     // begin
     // rr[i,k]:=r[i] mod 10;
     // r[i]:=r[i] div 10;
     // end;
  for i:=1 to 10000 do re[i]:=r[i];
  q:=1;
  c:=10000;
  {while c-q>1 do
    begin
    while re[q]<0.5 do inc(q);
    while re[c]<0.5 do dec(c);
    if (q+c) mod 2 = 0 then
      begin
      if re[q]<re[c] then mm:=re[q] else mm:=re[c];
      re[(q+c) div 2]:=re[(q+c) div 2]+mm+mm;
      re[q]:=re[q]-mm;
      re[c]:=re[c]-mm;
      end
    else
      begin
      if re[q]<re[c] then mm:=re[q] else mm:=re[c];
      re[(q+c)div 2]:=re[(q+c)div 2]+mm;
      re[(q+c)div 2+1]:=re[(q+c)div 2+1]+mm;
      re[q]:=re[q]-mm;
      re[c]:=re[c]-mm;
      end;
    end;
  res:=0.0;   {}
  for c:=1 to 10000 do res:=res+r[c]*c;
  res:=res/tot;
  writeln(res:0:20);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    re:array[0..10001]of extended;
    rr:array[0..10001,0..30] of longint;
    res,tot:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        writeln(c,' ',i,' ',k,' : ',cur);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  //for i:=1 to 10000 do
   // for k:=0 to 18 do
     // begin
     // rr[i,k]:=r[i] mod 10;
     // r[i]:=r[i] div 10;
     // end;
  for i:=1 to 10000 do re[i]:=r[i]/tot;
  if (tot>1e19) then runerror(239);
  //q:=1;
  //c:=10000;
  //while c-q>1 do
  //  begin
  //
  //  end;
  res:=0.0;
  for c:=1 to 10000 do res:=res+re[c]*c;
  writeln(res:0:20);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of longint;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of extended;
    res,cur,tot:extended;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0.0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1.0;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1.0; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  res:=0.0;
  for c:=1 to 10000 do res:=res+r[c]*c;
  res:=res/tot;
  writeln(res:0:15);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    res,tot:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  res:=0.0;
  for c:=1 to 10000 do res:=res+(r[c]+0.0)*c;
  res:=res/tot;
  writeln(res:0:20);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    res,tot:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  res:=0.0;
  for c:=1 to 10000 do res:=res+r[c]*c;
  res:=res/tot;
  writeln(res:0:18);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    res,tot:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,mm,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur:0:2);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  res:=0.0;
  for c:=1 to 10000 do res:=res+r[c]*c;
  res:=res/tot;
  writeln(res:0:12);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.

{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE CONSOLE}

const filename='c';
      oo=maxlongint div 2;
      eps=1e-6;
      eee=1e-21;

var qq,cc,dd,a,aa:array[0..1000000]of int64;
    qc,he:array[0..2014,0..2014]of longint;
    r:array[0..10001]of int64;
    re:array[0..10001]of extended;
    rr:array[0..10001,0..30] of longint;
    res,tot,mm:extended;
    cur:int64;
    poss:boolean;
    s,ss,sss,s0,s1,s2,s3:string;
    x,y,z,xx,yy,zz,x0,y0,z0,x1,x2,x3,y1,y2,y3,z1,z2,z3:extended;
    nt,ii,jj,kk,nn,n,m,q,c,q0,c0,q1,c1,q2,c2,q3,c3,max,min:longint;
    test,ll,t,tt:longint;
    b,bb,bbb,b0,b1,b2,b3:boolean;

function mx(q,c:longint):longint;
  begin
  if q>c then mx:=q else mx:=c;
  end;

function mn(q,c:longint):longint;
  begin
  if q<c then mn:=q else mn:=c;
  end;

procedure init;
  begin
  assign(input,filename+'.in');
  assign(output,filename+'.out');
  reset(input);
  rewrite(output);
  end;

procedure fin;
  begin
  close(input);
  close(output);
  end;

procedure clear;
var i,j,k:longint;
  begin
  fillchar(qc,sizeof(qc),0);
  end;

procedure load;
var i,j,k:longint;
  begin
  end;

procedure save;
var i,j,k:longint;
  begin
  end;

procedure run;
var i,j,k:longint;
  begin
  //init;
  read(n);
  for i:=1 to n do read(qq[i],cc[i]);
  tot:=1.0;
  for i:=1 to n do tot:=tot*(cc[i]-qq[i]+1);
  for i:=1 to n do dd[i]:=cc[i]-qq[i]+1;
  for i:=1 to 10000 do r[i]:=0;

  for c:=1 to 10000 do
  for i:=1 to n do
  if ((qq[i]<=c)and(c<=cc[i])) then
    begin
    for k:=1 to n do

    if (k<>i) then
      begin
      cur:=1;
      poss:=true;
      q:=qq[k];
      if c>=q then q:=c+1;
      if (cc[k]<q) then poss:=false else cur:=cur*(cc[k]-q+1);

      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<q then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<i))) then poss:=false else
            if ((j>i)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      poss:=false;

      if ((qq[k]<=c)and(c<=cc[k])and(k>i)) then begin poss:=true; cur:=1; end;
      for j:=1 to n do
        if ((j<>k)and(j<>i)) then
          begin
          q:=cc[j];
          if c<cc[j] then q:=c;
          if ((qq[j]>q)or((qq[j]=q)and(j<k))) then poss:=false else
            if ((j>k)or(q<c)) then cur:=cur*(q-qq[j]+1) else cur:=cur*(q-qq[j]);
          end;

      if poss then
        begin
        r[c]:=r[c]+cur;
        //writeln(c,' ',i,' ',k,' : ',cur);
        end;
      //or((cc[k]=q)and(k<i)))
         // else
       // if ((k>i)or(q>c)) then cur:=cur*(cc[k]-q+1) else cur:=cur*(cc[k]-q);
      end;
    end;

  //for i:=1 to 10000 do
   // for k:=0 to 18 do
     // begin
     // rr[i,k]:=r[i] mod 10;
     // r[i]:=r[i] div 10;
     // end;
  for i:=1 to 10000 do re[i]:=r[i];
  q:=1;
  c:=10000;
  {while c-q>1 do
    begin
    while re[q]<0.5 do inc(q);
    while re[c]<0.5 do dec(c);
    if (q+c) mod 2 = 0 then
      begin
      if re[q]<re[c] then mm:=re[q] else mm:=re[c];
      re[(q+c) div 2]:=re[(q+c) div 2]+mm+mm;
      re[q]:=re[q]-mm;
      re[c]:=re[c]-mm;
      end
    else
      begin
      if re[q]<re[c] then mm:=re[q] else mm:=re[c];
      re[(q+c)div 2]:=re[(q+c)div 2]+mm;
      re[(q+c)div 2+1]:=re[(q+c)div 2+1]+mm;
      re[q]:=re[q]-mm;
      re[c]:=re[c]-mm;
      end;
    end;
  res:=0.0;   {}
  for c:=1 to 10000 do res:=res+r[c]*c;
  res:=res/tot;
  writeln(res:0:20);
  //fin;
  end;

begin
nt:=1;
//readln(nt);
for test:=1 to nt do
  begin
  clear;
  load;
  run;
  save;
  end;
end.