Mirror Brackets
시간 제한1초메모리 제한1024 MB
문자와 괄호가 섞인 올바른 괄호열이 주어지면, 안쪽 괄호쌍부터 내용을 괄호 종류에 따라 좌우 또는 상하로 뒤집어가며 모든 괄호가 사라질 때까지 바꾼 결과를 구한다.
문제
Let's remind you what a correct bracket sequence (CBS) is.
- An empty string is CBS.
- If is CBS, then
()and[]also are CBS. - If and are CBS, then also is CBS.
- If a sequence can't be obtained applying the rules given above, then it is not a CBS.
Vasya wrote a correct bracket sequence consisting of brackets "(", ")", "[" and "]". After that Vasya added to some places of the sequence characters "b", "d", "o", "p", "q" and "x". As a result, Vasya got some string .
Now Vasya performs the following operations:
If has a substring of the form () (there are no brackets in ), then Vasya replaces it with string's mirror reflection relative to vertical axis. If contains a substring of the form [] (there are no brackets in as well), then Vasya replaces it with string's mirror reflection relative to horizontal axis. For example, substring "(qbpoxd)" will be replaced with "bxoqdp", and substring "[qbpoxd]" will be replaced with "dpboxq".
Vasya performs operations until there are no brackets left in the string.
Calculate by the given string what result Vasya will have in the end.
입력
The only line contains the string whose length does not exceed characters, consisting of characters "(", ")","[", "]", "b", "d", "o", "p", "q" and "x". It is guaranteed that all the brackets in organize a correct bracket sequence. It is also guaranteed that the input data contain at least one letter.
출력
Print the string Vasya will get in the end.