#include #include using namespace std; const int MAXN = 2005, Mod = 998244353; string s; int T, n, m, a[MAXN], dp[MAXN][MAXN], d[MAXN][MAXN]; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> s, s = " " + s + " ", dp[0][n] = 1; for (int i = 0; i <= n; i++) { for (int j = n; j >= 0; j--) { (d[i][j] += d[i][j + 1]) %= Mod; (dp[i][j] += d[i][j]) %= Mod; if (s[i + 1] == '1' && j) { dp[i + 1][j - 1] = (dp[i + 1][j - 1] + 1ll * j * dp[i][j]) % Mod; } else if (s[i + 1] == '0') { dp[i + 1][j] = (dp[i + 1][j] + 1ll * (n - i - j) * dp[i][j]) % Mod; if (j) (d[i + 1][j - 1] += dp[i][j]) %= Mod; } } } cout << dp[n][0]; return 0; }