시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 9 1 1 11.111%

## 문제

Karen and her friends play in a music band in Karen's garage. She has complicated thoughts on which subsets of the band should be allowed to enter the garage. She designed a boolean formula $F$ in which each variable denotes the presence of a certain band member. She wants a group of people to be able to enter the garage if and only if $F$ is true.

You are asked to create a system of wires and locks that will fulfill the formula $F$. Each band member will receive a key that opens all the locks that are denoted by their letter.

For example, suppose that $F = a \lor (b \land c)$ and band members $a$ and $b$ are present. Then they should be able to enter the garage with their keys because $true \lor (true \land false) = true$.

A band member doesn't have to use their key to open all the locks possible. For example, suppose that $F = a \oplus b$. Then band member $a$ alone should be able to enter the garage because $true \oplus false = true$. But if both $a$ and $b$ come to the garage, they can just disregard $b$'s key and open the garage using $a$'s one. However, $true \oplus true = false$, so this formula $F$ is not fulfillable.

The system must be a rectangular grid of size at most $50 \times 50$ containing horizontal wires '-', vertical wires '|', wire connections '+', and locks. The upper leftmost and the upper rightmost cells of the grid must contain wire connections that will be attached to the doors of the garage. The garage doors stay closed as long as there is a path between these two connections via wires and locked locks.

You are to design such a system corresponding to the given formula $F$, or to state that there is no such system.

## 입력

The input contains a non-empty boolean formula $F$.

The formula can contain letters a, ..., h denoting the presence of band members, operators "and", "or", "not", and parentheses. The length of the formula does not exceed 2020. The "not" operator has the highest priority. The "and" operator has higher priority than the "or" operator. There are single spaces around each "and", around each "or", and after each "not". There are no spaces other than those.

## 출력

If it is impossible to design the desired system, print one line "IMPOSSIBLE".

Otherwise, output a rectangular grid of characters --- the system corresponding to formula $F$. The system can only contain spaces, '-', '|', '+', and letters corresponding to the band members that are mentioned in the input.

The upper leftmost and the upper rightmost cells should be wire connections. The width of the grid should be between 2 and 50, inclusive, the height of the grid should be between 1 and 50, inclusive.

Character '-' must be used for a wire if and only if it connects something on the left and something on the right with empty cells below and above. Similarly, '|' must be used for a wire if and only if it connects something below and something above with empty cells on the left and on the right.

## 예제 입력 1

a or (b and c)


## 예제 출력 1

+-+ +b-+
| | |  |
+-a-+-c+


## 예제 입력 2

(a or f) and ((a and g) or (a and h))


## 예제 출력 2

+a-f+
|   |
+g+h+
a | a
+-+-+


## 예제 입력 3

a and not b or not a and b


## 예제 출력 3

IMPOSSIBLE


## 예제 입력 4

b or not b


## 예제 출력 4

+ +


## 예제 입력 5

d and not d


## 예제 출력 5

+  +---+  +---+--+---+
|  |      |   |  |
+--+      +---+  |
|  |      |      |
+  +------+      +---+