#include<bits/stdc++.h>
using namespace std;#defineintlonglong#definesz(X)((int)(X).size())#definefifirst#definesesecond#definepbpush_back#definerep(i, a, n)for(int i = a; i <= n; i ++)#defineper(i, a, n)for(int i = n; i >= a; i --)#definemstmemset#defineendl'\n'#definesi(x)scanf("%d",&x)#definesll(x)scanf("%lld",&x)#definepi(x)printf("%d\n", x)#definepll(x)printf("%lld\n", x)#definescscanf#defineprprintf#defineIOios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
using big =longlong;
using i64 =unsignedlonglong;constint SIZE =2e5+10, INF =0x3f3f3f3f3f3f3f3f;int dx[]={-1,0,1,0};int dy[]={0,1,0,-1};
big gcd(big a, big b){return b ?gcd(b, a % b): a;}
big ksm(int a,int b,int c){int ans =1% c;while(b){if(b &1){ ans =1ll* ans * a % c;} a =1ll* a * a % c; b >>=1;}return ans;}
constexpr int N =1010;int n, m, c, dp[N][N], s[N][N], a[N][N];voidsolve(){
cin >> n >> m >> c;rep(i,1, n){rep(j,1, m){ cin >> a[i][j];}}memset(dp,0x3f,sizeof dp);rep(i,1, n){rep(j,1, m){
dp[i][j]=min({a[i][j], dp[i -1][j]+ c, dp[i][j -1]+ c});}}int ans = INF;rep(i,1, n){rep(j,1, m){
ans =min({ans, dp[i -1][j]+ c + a[i][j], dp[i][j -1]+ c + a[i][j]});}}
cout << ans <<'\n';}signedmain(void){int t;// cin >> t; // in(t);
t =1;while(t --){solve();}return0;}
2.AtCoder Beginner Contest 210 E - Chain Contestant
#include<bits/stdc++.h>
using namespace std;
constexpr int N =1025, P =998244353;
string str;int n;// assume -P <= x < 2Pintnorm(int x){if(x <0){
x += P;}if(x >= P){
x -= P;}return x;}
template<class T>
T power(T a,int b){
T res =1;for(; b; b /=2, a *= a){if(b %2){
res *= a;}}return res;}structZ{int x;Z(int x =0):x(norm(x)){}intval()const{return x;}
Z operator-()const{returnZ(norm(P - x));}
Z inv()const{assert(x !=0);returnpower(*this, P -2);}
Z &operator*=(const Z &rhs){
x =(longlong)(x)* rhs.x % P;return*this;}
Z &operator+=(const Z &rhs){
x =norm(x + rhs.x);return*this;}
Z &operator-=(const Z &rhs){
x =norm(x - rhs.x);return*this;}
Z &operator/=(const Z &rhs){return*this *= rhs.inv();}
friend Z operator*(const Z &lhs,const Z &rhs){
Z res = lhs;
res *= rhs;return res;}
friend Z operator+(const Z &lhs,const Z &rhs){
Z res = lhs;
res += rhs;return res;}
friend Z operator-(const Z &lhs,const Z &rhs){
Z res = lhs;
res -= rhs;return res;}
friend Z operator/(const Z &lhs,const Z &rhs){
Z res = lhs;
res /= rhs;return res;}};
Z f[N][N][10];signedmain(void){
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> str;for(int i =1; i <= str.size(); i ++){for(int j =0; j <(1<<10); j ++){for(int k =0; k <10; k ++){
f[i][j][k]= f[i -1][j][k];}}int x = str[i -1]-'A';for(int j =0; j <(1<<10); j ++){if((j >> x)&1){
f[i][j][x]+= f[i -1][j][x];for(int k =0; k <10; k ++){if(k != x){
f[i][j][x]+= f[i -1][j ^(1<< x)][k];}}}}
f[i][1<< x][x]+=1;}
Z ans;for(int i =0; i <(1<<10); i ++){for(int j =0; j <10; j ++){
ans += f[n][i][j];}}
cout << ans.val()<<'\n';return0;}