#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i) #define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i) #define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i) #define fi first #define se second #define pb push_back #define mp make_pair #define dbg(x) cerr<<#x" = "<<x<<endl #define debug(...) fprintf(stderr, __VA_ARGS__) #define Es(x,i) for(Edge *i=G[x];i;i=i->nxt) typedef long long ll; typedef pair<int,int> pii; const int inf=~0u>>1,mod=1e9+7; inline int rd() { int x,c,f=1;while(!isdigit(c=getchar()))f=c!=‘-‘;x=c-‘0‘; while(isdigit(c=getchar()))x=x*10+c-‘0‘;return f?x:-x; }
frw
char *TT,*mo,but[(1<<15)+2]; #define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++) char butt[(1<<15)+2],*bp=butt,*bq=butt+(1<<15); inline void pr(char x){ *bp=x;(++bp==bq)?fwrite(butt,1,1<<15,stdout),bp=butt:0; } inline void write(int x){ if(!x)pr(‘0‘); else{ if(x<0)pr(‘-‘),x=-x; static int s[12]; int p=0; while(x)s[p++]=x%10,x/=10; per(i,0,p-1)pr(s[i]+‘0‘); } }
struct Rand{ Rand(){srand(time(0));} operator int(){return (rand()<<15)^rand();} operator ll(){ll a=rand(),b=rand(),c=rand(),d=rand();return (a<<45)^(b<<30)^(c<<15)^d;} }_r;
namespace Math{ inline ll mul(ll n,ll m,ll p){ll r=0;for(;m;m>>=1,n=(n+n)%p)if(m&1)r=(r+n)%p;return r;} inline int pw(int n,int m,int p){int r=1;for(;m;m>>=1,n=(ll)n*n%p)if(m&1)r=(ll)r*n%p;return r;} inline ll pwl(ll n,ll m,ll p){ll r=1;for(;m;m>>=1,n=mul(n,n,p))if(m&1)r=mul(r,n,p);return r;} const int pri[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; inline bool isp_bf(ll n){ if(n<2)return 0; if(n==2)return 0; for(ll i=2;i*i<=n;++i){ if(n%i==0)return 0; } return 1; } inline bool Miller_rabin(ll n){ ll q=n-1;int y=0; while(!(q&1))q>>=1,++y; For(i,0,7){ ll x=pwl(pri[i],q,n); For(_,0,y){ ll t=mul(x,x,n); if(t==1){ if(x!=1&&x!=n-1)return 0; else{x=1;break;} } x=t; } if(x!=1)return 0; } return 1; } inline bool isp(ll n){ if(n>2&&!(n&1))return 0; if(n<=1000)return isp_bf(n); else return Miller_rabin(n); } }
#define I inline #define OP operator #define RT return *this I bool IS(char x){return x==10||x==13||x==‘ ‘;} struct Cg{I char OP()(){return getchar();}};struct Cp{I void OP()(char x){putchar(x);}}; #define RX char c,f=1;while(!isdigit(c=P()))f=c!=‘-‘;x=c-‘0‘;while(isdigit(c=P()))x=x*10+c-‘0‘;x=f?x:-x #define TR *this,x;return x struct Fr{Cg P;I Fr&OP,(int&x){RX;RT;}I OP int(){int x;TR;}I Fr&OP,(ll &x){RX;RT;}I OP ll(){ll x;TR;} I Fr&OP,(char&x){while(IS(x=P()));RT;}I OP char(){char x;TR;} I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS(t)&&~t;t=P())*x++=t;}*x++=0;RT;}}in; #define WI if(x){if(x<0)P(‘-‘),x=-x;char s[22],c=0;while(x)s[c++]=x%10+‘0‘,x/=10;while(c--)P(s[c]);}else P(‘0‘) struct Fw{Cp P;I Fw&OP,(int x){WI;RT;}I Fw&OP,(ll x){WI;RT;}I Fw&OP,(char x){P(x);RT;} I Fw&OP,(const char *x){while(*x)P(*x++);RT;}}out;