#include #define _1 (__int128)1 using namespace std; using ll = long long; void FileIO (const string s) { freopen(string(s + ".in").c_str(), "r", stdin); freopen(string(s + ".out").c_str(), "w", stdout); } const int N = 2010, mod = 998244353; int n, dp[N][N], sum[N][N]; string s; signed main () { ios::sync_with_stdio(0), cin.tie(0); // FileIO(""); cin >> n >> s, s = " " + s; 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] = (1ll * dp[i - 1][j] * (n - i - j + 1) + sum[i - 1][j + 1]) % mod; else dp[i][j] = 1ll * (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; }