#include using namespace std; const int mod=998244353; int main(){ int n; cin>>n; string s; cin>>s; s=" "+s; vector> dp(n+2,vector (n+2)); vector> sum(n+2,vector (n+2)); dp[0][n]=1; for (int i=1; i<=n; i++) { sum[0][i]=1; } for (int i=1; i<=n; i++) { for (int j=0; j<=n; j++) { if (s[i]=='0') { dp[i][j]=(dp[i-1][j]*(n-i-j+1)+sum[i-1][j+1])%mod; } else { dp[i][j]=(j+1)*dp[i-1][j+1]%mod; } } for (int j=n; j; j--) { sum[i][j]=(sum[i][j+1]+dp[i][j])%mod; } } cout << dp[n][0]; return 0; }