시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 (추가 시간 없음) 1024 MB76343251.613%

문제

You are given a bracket sequence consisting of $N$ open brackets and $N$ closed brackets. Let $S$ be a nonempty set of integers between $1$ and $2N$, inclusively. You can choose two indices in $S$, not necessarily adjacent, and swap the brackets of the bracket sequence at those two positions.

Find the number of $S$ that can result in a proper bracket sequence by repeatedly applying this operation arbitrary number of times.

입력

The first line contains one integer $N$.

The second line contains a string of $2N$ brackets, either ( or ).

출력

Print the number of all possible $S$ in modulo $998\, 244\, 353$. $998\, 244\, 353$ is a prime number.

제한

  • $1\leq N\leq 3000$
  • Given bracket sequence contains $N$ open brackets and $N$ closed brackets.

예제 입력 1

3
())(()

예제 출력 1

36

예제 입력 2

6
()))(())()((

예제 출력 2

1536