#include #include #include #include using namespace std; typedef long long ll; const ll mod = 998244353; template T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; } template T mod_inv(T a, T m) { T x, y; extgcd(a, m, x, y); return (m + x % m) % m; } ll pw(ll a, ll b){ ll x = 1; while (b){ while(!(b&1)){ (a *= a) %= mod; b /= 2; } (x *= a) %= mod; b--; } return x; } void _ntt(vector &a,int sign) { int i,j,k,n = a.size(),m = 1; while(m> 1); k>(i ^= k); k >>= 1); if(j=mod) a[k] -= mod; a[k + i] = u - d; if(a[k + i]<0) a[k + i] += mod; } (w *= base) %= mod; } } for(ll x: a){ if(x<0) x += mod; } } void ntt(vector& input) { _ntt(input, 1); } void intt(vector& input) { _ntt(input, -1); ll x = input.size(); const int n_inv = mod_inv(x, mod); for (auto& x : input) (x *= n_inv) %= mod; } ll a[140000] = {},b[140000] = {},ans[100010],c[200010]; int p,gen = -1; bool gensi(ll g){ int i; ll ret = 1; for(i=1;i

u(262144),v(262144); int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int i; cin >> p; for(i=1;i> a[i]; for(i=1;i> b[i]; vector w; for(i=1;i