const
    whitespaces = [#09, ' ', #13, #10];

type
    tstate = (_START_, _LINE_);

var
    state: tstate;
    indent: longint;
    ch: char;
begin
    state := _START_;
    indent := 0;

    while not eof do begin
        repeat
            read(ch);
        until not (ch in whitespaces);
        if ch = #27 then break;
        case state of
            _START_:
                begin
                    if ch = '{' then begin
                        writeln('': indent * 4, '{');
                        inc(indent);
                    end else if ch = '}' then begin
                        dec(indent);
                        state := _LINE_;
                        write('': indent * 4, '}');
                    end else begin
                        state := _LINE_;
                        write('': indent * 4, ch);
                    end;
                end;
            _LINE_:
                begin
                    case ch of
                        ',': write(', ');
                        '{':
                            begin
                                writeln(' {');
                                inc(indent);
                                state := _START_;
                            end;
                        '}':
                            begin
                                dec(indent);
                                writeln;
                                write('': indent, '}');
                            end;
                        ';':
                            begin
                                writeln(';');
                                state := _START_;
                            end;
                        else begin
                            write(ch);
                        end;
                    end;
                end;
        end;
    end;
end.