var x:array [1..1000, 1..1000] of char;
    n, i, j, k, l, p, s:integer;

begin
  reset (input, 'table.in'); rewrite (output, 'table.out');
  fillchar (x, sizeof (x), 32);
  read (n);
  for i:=1 to n do begin
    read (k); p:=2; x[i*2-1, 1]:='+'; x[i*2, 1]:='|'; x[i*2+1, 1]:='+';
    for j:=1 to k do begin
      read (s);
      for l:=1 to s do begin
        if x[i*2-1, p]=' ' then x[i*2-1, p]:='-';
        x[i*2+1, p]:='-';
        inc (p);
      end;
      x[i*2-1, p]:='+'; x[i*2, p]:='|'; x[i*2+1, p]:='+';
      inc (p);
    end;
  end;
  for i:=1 to 2*n+1 do begin
    k:=0; for l:=1000 downto 1 do if x[i, l]<>' ' then begin k:=l; break end;
    for l:=1 to k do write (x[i, l]); writeln;
  end;
end.