Instruens Fabulam

Time limit1sMemory limit128 MB

Problem

Instruens Fabulam is Latin for "drawing a chart (or table)", and that is exactly what you will do in this problem.

Given the data for one or more tables, print each table in the prescribed format, complete with a border and per-column alignment.

Input

The input consists of one or more table descriptions, followed by a line whose first character is *, which signals the end of the input.

Each description begins with a header line: one or more characters that define the number of columns and the alignment of each column. Each character is <, =, or >, meaning left-justified, centered, or right-justified respectively.

After the header come between 2 and 21 data lines, one per row. Each data line consists of one or more nonempty entries separated by &, and the number of entries equals the number of columns defined by the header. The first data line holds the column titles; the remaining data lines hold the body of the table.

Spaces may appear inside an entry, but never at the beginning or end of an entry. The characters <, =, >, &, and * never appear in the input except where described above.

Output

For each table description, print the table using the following rules.

  • The total width of the table never exceeds 79 characters (not counting the end-of-line).
  • Each column is as wide as its longest entry, and columns are separated by the vertical bar |. The longest entry in a column is separated from the enclosing | bars by exactly one space.
  • Horizontal lines are drawn with dashes -, not underscores _. An at sign @ marks each of the four outer corners. A plus sign + marks each column boundary on the line that separates the title row from the body.
  • If a centered entry cannot be placed exactly in the center of its column, the leftover space goes on the right side of the entry.

The input and the correct output satisfy all of the formatting requirements above, except that the output may contain two or more consecutive spaces. There are no spaces at the beginning or end of any line, and only spaces (never tabs) are used.