多项式全家桶
#include<bits/stdc++.h>
#define Fu(i,a,b) for(register int i=a;i<=b;i++)
#define Fd(i,a,b) for(int i=a;i>=b;i--)
#define mod 998244353
using namespace std;
int ksm(int a,int k){
int ans=1;
while(k){
if(k&1) ans=1ll*ans*a%mod;
a=1ll*a*a%mod,k>>=1;
}return ans;
}
const int N=4*1e5+5;
int rev[N],g=3,gi=ksm(3,mod-2);
void ntt(int n,int *a,int inv){
Fu(i,0,n) if(i<rev[i]) swap(a[i],a[rev[i]]);
for(int len=1;len<n;len<<=1){
int wn=ksm(inv?g:gi,(mod-1)/(len<<1));
for(int i=0;i<n;i+=len<<1){
int w0=1;
Fu(j,0,len-1){
int x=a[i+j],y=1ll*w0*a[i+j+len]%mod;
a[i+j]=(x+y)%mod,a[i+j+len]=(x-y+mod)%mod,w0=1ll*w0*wn%mod;
}
}
}
}
int c[N];
void mul(int *a,int *b,int n){
int len=1,bit=0;
while(len<2*n) len<<=1,bit++;
Fu(i,0,len) rev[i]=(rev[i>>1]>>1)|((i&1)<<bit-1),c[i]=i<n?b[i]:0;
ntt(len,a,1),ntt(len,c,1);
Fu(i,0,len) a[i]=1ll*a[i]*c[i]%mod;
ntt(len,a,0);
Fu(i,0,len) a[i]=i<n?1ll*a[i]*ksm(len,mod-2)%mod:0;
}
void inv(int *a,int *b,int n){
if(n==1){
a[0]=ksm(b[0],mod-2);
return ;
}inv(a,b,n+1>>1);
int len=1,bit=0;
while(len<2*n) len<<=1,bit++;
Fu(i,0,len) rev[i]=(rev[i>>1]>>1)|((i&1)<<bit-1),c[i]=i<n?b[i]:0;
ntt(len,a,1),ntt(len,c,1);
Fu(i,0,len) a[i]=1ll*a[i]*(2ll-1ll*a[i]*c[i]%mod+mod)%mod;
ntt(len,a,0);
Fu(i,0,len) a[i]=i<n?1ll*a[i]*ksm(len,mod-2)%mod:0;
}
int inv2=ksm(2,mod-2),d[N];
void sqr(int *a,int *b,int n){
if(n==1){
a[0]=1;
return ;
}sqr(a,b,n+1>>1);
Fu(i,0,n) d[i]=0;
inv(d,a,n),mul(a,a,n);
Fu(i,0,n) a[i]=1ll*inv2*(a[i]+b[i])%mod;
mul(a,d,n);
}
void ln(int *a,int *b,int n){
memset(d,0,sizeof(d));
inv(d,b,n);
Fu(i,1,n-1) a[i-1]=1ll*b[i]*i%mod;
a[n-1]=0;
mul(a,d,n);
Fd(i,n-1,1) a[i]=1ll*a[i-1]*ksm(i,mod-2)%mod;
a[0]=0;
}
int e[N];
void exp(int *a,int *b,int n){
if(n==1){
a[0]=1;
return ;
}exp(a,b,n+1>>1);
ln(e,a,n);
Fu(i,0,n-1) e[i]=(b[i]-e[i]+mod)%mod;
e[0]++;
mul(a,e,n);
}
int n,m,a[N],b[N];
int main(){
return 0;
}