When scientists rediscovered the ancient Maya cities, they found many texts written in an unknown script. One example is the name of K’ak’-u-pakal, a military leader and priest of the ancient Maya city of Chichén Itzá (see A. W. Voss, H. J. Kremer, K’ak’-u-pakal, Hun-pik-tok’ and the Kokom for details). This hieroglyph appears at many sites throughout the city.
Maya hieroglyphs are not hieroglyphs in the strict sense, but compositions of separate glyphs. Every known glyph (there are about one thousand of them) is indexed with a number from 1 to 9999. A special language for encoding the relative positions of glyphs makes it possible to write any hieroglyph as plain text. For example, the K’ak’-u-pakal hieroglyph above is encoded as ((669:604).(586:(27:[(534.534)]))). The formal grammar of the language (adapted for this contest) is:
<inscription> ::= <glyph-id>
| '(' <block> '.' <horizontal-group> ')'
| '(' <block> ':' <vertical-group> ')'
<horizontal-group> ::= <block> ['.' <horizontal-group>]
<vertical-group> ::= <block> [':' <vertical-group>]
<block> ::= <inscription> | '[' <inscription> ']'
The encoding describes how a hieroglyph is composed: glyphs are combined horizontally or vertically (using . or :) into blocks, which are in turn combined into larger and larger blocks until the required configuration is reached.
Given such an encoding, produce the hieroglyph's layout as ASCII art.
The first line contains a single space-free text string (at most 255 characters) that encodes one Maya hieroglyph in plain-text form.
Print the layout, composed of the characters +, -, |, space (ASCII codes 43, 45, 124, 32), the digits 0-9, and line feeds.
Within any group all blocks must have exactly the same size, except a block enclosed in square brackets (there is at most one such block per group), which must be exactly twice as wide (or twice as tall if the group is vertical).
The glyph id, with one leading and one trailing space, is placed at the upper-left corner of its block. The size of the output (in bytes) must be as small as possible. It is guaranteed that a valid layout exists and that it fits in at most 100000 bytes.