{$H+}
{$C+}
{$inline on}
program mwr09;

uses mtx09;

// TODO use fmt integer to choose number of sign. digit
// between  3 and 16 for double (real*8)
var
  fmt:boolean=true; // pretty/ugly output

{}procedure writx(var f: text; x: double);
const
  r=4.99E-7;
  wd=0; // using tab as delimiter so fieldwidth 0 is ok
  sf=6; // was 5 check that it makes no problem
var
  y:double; p,pp,de,w,dc:longint;
  intg,n,ne:boolean;
begin
  if (abs(x)<=maxint) then intg:=abs(x-trunc(x))=0 else intg:=false;
  if intg then write(f,trunc(x):wd) else begin
    n := x<0;
    if n then y:=-x else y:=x;
    p:=0;
    while (y>=10) do begin y:=y/10; p:=succ(p) end;
    while (y<1)   do begin y:=y*10; p:=pred(p) end;
    if (p=0) then write(f,x:wd:sf-1) else begin
      ne:=p<0;
      if ne then pp:=-p else pp:=p;
      de:=2;
      while (pp>9) do begin pp:=pp div 10; de:=succ(de) end;
      if ne then de:=succ(de);
      y:=y+double(r);
      w:=wd-de;
      if (p>-(sf-2)) and (p<sf) then begin
        dc:=pred(sf-p);
        if (dc<1) then dc:=1;
        write(f,x:wd:dc) // TODO check if sf=6 make sense ?
      end else
        if n then write(f,-y:w:pred(sf),'E',p:1)
             else write(f,y:w:pred(sf),'E',p:1)
    end
  end
end;

// simplified version with tab delimited elements
// simple with spreadsheet and cut/paste/awk
// either full precision ugly exponential fmt=false
// or prettier 6 digits output with identification of integers
procedure mwr9(a:mtx; var f:text);
var
   i, j, ia, ia1: longint;
begin
  if a.nam<>'' then writeln(f,a.nam);
  ia1 := 1;
  for i := 1 to a.lgn do begin
    ia := ia1;
    if fmt then writx(f,a.e[ia]) else write(f,a.e[ia]);
    ia := ia + a.dl;
    for j := 2 to a.col do begin
      write(#9);
      if fmt then writx(f,a.e[ia]) else write(f,a.e[ia]);
      ia := ia + a.dl;
    end;
    ia1 := ia1 + a.dc;
    writeln(f);
  end;
  writeln(f);
  flush(f);
end;

procedure mwr9(a:mtx); inline;
begin
  mwr9(a,output)
end;

// (re)write to file name "s" wrt to stream to append
procedure mwr9(a:mtx; s:string); inline;
var
  f: text;
begin
  {$I-}
  assign(f,s);
  system.rewrite(f);
  if ioresult<>0 then exit;
  mwr9(a,f);
  flush(f);
  close(f);
  {$I+}
end;

var
  m: mtx;
  s: string;
begin
  while true do begin
    readln(s);
    equ(m,s);
    fmt := true; mwr9(m);
    fmt := false; mwr9(m);
  end
end.
