Codeforces Round 288 (Div. 2)
E
Arthur and Brackets
Codeforces
2200
原题
← D→
翻译中…

Notice that the memory limit is non-standard.

翻译中…

Recently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even got himself a favorite correct bracket sequence of length $2*n*$. Unlike Arthur, Sasha understood the topic very badly, and broke Arthur's favorite correct bracket sequence just to spite him.

翻译中…

All Arthur remembers about his favorite sequence is for each opening parenthesis ('(') the approximate distance to the corresponding closing one (')'). For the $*i*$-th opening bracket he remembers the segment $[*l*_{*i*}, *r*_{*i*}]$, containing the distance to the corresponding closing bracket.

翻译中…

Formally speaking, for the $*i*$-th opening bracket (in order from left to right) we know that the difference of its position and the position of the corresponding closing bracket belongs to the segment $[*l*_{*i*}, *r*_{*i*}]$.

翻译中…

Help Arthur restore his favorite correct bracket sequence!

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 600$), the number of opening brackets in Arthur's favorite correct bracket sequence.

翻译中…

Next $*n*$ lines contain numbers $*l*_{*i*}$ and $*r*_{*i*}$ ($1 ≤ *l*_{*i*} ≤ *r*_{*i*} < 2*n*$), representing the segment where lies the distance from the $*i*$-th opening bracket and the corresponding closing one.

翻译中…

The descriptions of the segments are given in the order in which the opening brackets occur in Arthur's favorite sequence if we list them from left to right.

翻译中…

Output

翻译中…

If it is possible to restore the correct bracket sequence by the given data, print any possible choice.

翻译中…

If Arthur got something wrong, and there are no sequences corresponding to the given information, print a single line "IMPOSSIBLE" (without the quotes).

翻译中…

样例

Input #1
4
1 1
1 1
1 1
1 1
Output #1
()()()()
InputCopy OutputCopy
Input #2
3
5 5
3 3
1 1
Output #2
((()))
InputCopy OutputCopy
Input #3
3
5 5
3 3
2 2
Output #3
IMPOSSIBLE
InputCopy OutputCopy
Input #4
3
2 3
1 4
1 4
Output #4
(())()
InputCopy OutputCopy
题目信息
题号
508E
时间限制
2 s
内存限制
128 MB
标签
动态规划
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。