#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int n,m; vector c; void dfs(int cur,int cv){ if(cur==n){ c[cv] ++; return; } rep(i,m-1){ if(cur%2==0){ dfs(cur+1,(cv+i)%m); } else{ dfs(cur+1,(cv-i+m)%m); } } } bool check(int l,int r){ if(l<=r){ if(l<=1&&1<=r)return true; } else{ if(r>=1)return true; } return false; } int main(){ cin>>n>>m; /* c.resize(m,0); dfs(0,0); rep(i,m){ cout< a(n); int s= 0 ; rep(i,n){ cin>>a[i]; if(i%2==0){ s += a[i]; } else{ s += m-a[i]; } s %= m; } if(s!=0){ cout<<-1<r)ans++; //if(check(l,r))ans++; } else{ mint t = mint(m-1).pow(remain)+1; t /= m; ans += t * a[i]; if(check(l,r))ans--; //if(r==m-1 || l>r)ans--; } } if(i%2==0){ s += a[i]; } else{ s += m-a[i]; } s %= m; } //ans++; cout<