#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; const ll modc = 998244353; int main(){ ll N, cnt=0, k; string S; cin >> N >> S; vector> dp(N, vector(N)); dp[0][0] = 1; for (int i=0; i> pd(N, vector(N)); if (S[i] == '('){ cnt++; for (int j=0; j<=cnt; j++){ k = cnt-j; if (j) pd[j][k] += dp[j-1][k]; if (k) pd[j][k] += dp[j][k-1]; pd[j][k] %= modc; } } else{ cnt--; for (int j=0; j<=cnt; j++){ k = cnt-j; if (j+1