{$APPTYPE CONSOLE}
{$O-,Q+,R+}

program code_formatting;

uses
    sysutils;

type
    tstate = (_start, _lb, _lc);

const
    idchars = ['A'..'Z', 'a'..'z', '0'..'9'];
    whitespace = [' ', #9, #10, #13];
    other = [';', ',', '(', ')', '{', '}'];

    allowed = idchars + whitespace + other;

var
    ch: char;
    state: tstate;
    ident: longint;

procedure process(ch: char);
var
    i: longint;
begin
    if (ch in whitespace) then exit;
    if ch = '{' then
        inc(ident);
    case state of
        _start: begin
            writeln('{');
            state := _lb;
        end;
        _lb: begin
            if ch = '}' then
            begin
                dec(ident);
            end;
            for i := 1 to 4 * ident do
                write(' ');
            if ch = '{' then
                writeln(' {')
            else if ch = ',' then
                write(', ')
            else if ch = ';' then
                writeln(';')
            else
                write(ch);
            state := _lc;
        end;
        _lc: begin
            if ch = '{' then
                writeln(' {')
            else if ch = ',' then
                write(', ')
            else if ch = ';' then
                writeln(';')
            else
                write(ch);
            if (ch = '{') or (ch = ';') then
                state := _lb;
        end;
    end;
end;

procedure nextch;
begin
    if eof then
    begin
        ch := '!'
    end else begin
        read(ch);
        if not (ch in allowed) then runerror(239);
        process(ch);
    end;
end;

begin
    state := _start;
    ident := 0;
    repeat nextch until ch = '!';

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