시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 29 4 2 7.692%

문제

A bracket sequence consisting of ‘(’ and ‘)’ is defined to be valid as follows:

1. An empty sequence is valid.
2. If X is a valid bracket sequence, then (X) is a valid bracket sequence.
3. If X and Y are valid bracket sequences, then the concatenation of X and Y , Z = XY , is a valid bracket sequence.

For example, “(())”, “()()”, and “(()())()” are all valid bracket sequences, while “(” and “())” are invalid bracket sequences.

You get a bracket sequence from the professor of length n. However, it might not be valid at the moment. The professor asks you to check if it is possible to make the sequence valid by performing at most one segment inversion operation. That is, you may choose two 1-based indices l and r (1 ≤ l ≤ r ≤ n) and invert each bracket with an index in the closed interval [l, r]. After the inversion, a left bracket ‘(’ becomes a right bracket ‘)’, and a right bracket ‘)’ becomes a left bracket ‘(’.

You can make “())(” valid by inverting the segment [3, 4]. You can make “()))” valid by inverting the segment [3, 3], or alternatively by inverting the segment [2, 2]. However, there does not exist a segment you can invert to make “)))(” valid.

입력

The input consists of one line containing between 1 and 5 000 brackets.

출력

Output “possible” if you can make the bracket sequence valid by performing at most one segment inversion, or “impossible” otherwise.

예제 입력

()))


예제 출력

possible


예제 입력 2

)))(


예제 출력 2

impossible


예제 입력 3

()


예제 출력 3

possible