QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596716#9421. Sheriruthucup-team087#AC ✓494ms64032kbC++2021.6kb2024-09-28 16:19:522024-10-13 20:44:22

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 20:44:22]
  • 管理员手动重测本题所有得分≥97分的提交记录
  • 测评结果:AC
  • 用时:494ms
  • 内存:64032kb
  • [2024-09-28 17:53:21]
  • hack成功,自动添加数据
  • (/hack/924)
  • [2024-09-28 16:19:53]
  • 评测
  • 测评结果:100
  • 用时:468ms
  • 内存:64036kb
  • [2024-09-28 16:19:52]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
//#define int ll

bool dbg=false;

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;
using vvi=vc<vc<int>>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

ll rand_int(ll l, ll r) { //[l, r]
	//#ifdef LOCAL
	static mt19937_64 gen;
	/*#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif*/
	return uniform_int_distribution<ll>(l, r)(gen);
}

ll rand_int(ll k){ //[0,k)
	return rand_int(0,k-1);
}
string rand_string(int n,char lw,char up){
	string s(n,'?');
	rep(i,n)s[i]=rand_int(lw,up);
	return s;
}

int current_run_id,run_batch_size=1000;
int calc_random_limit(){
	return current_run_id/run_batch_size+1;
}
template<class t>
void generate_single(t&a){
	a=rand_int(1,calc_random_limit());
}
void generate_single(string&a){
	int n;generate_single(n);
	a=rand_string(n,'a','b');
}
template<class t,class u>
void generate_single(pair<t,u>&a){
	generate_single(a.a);
	generate_single(a.b);
}
//https://trap.jp/post/1224/
template<class... Args>
void input(Args&... a){
	if(dbg){
		(generate_single(a),...);
	}else{
		(cin >> ... >> a);
	}
}
#define INT(...) int __VA_ARGS__;input(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;input(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;input(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;input(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;input(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;input(__VA_ARGS__)
#define overload3(a,b,c,d,...) d
#define VI2(name,size) vi name(size);rep(i_##name,size)input(name[i_##name]);
#define VI3(name,size,offset) vi name(size);rep(i_##name,size)input(name[i_##name]),name[i_##name]+=offset;
#define VI(...) overload3(__VA_ARGS__,VI3,VI2)(__VA_ARGS__)
#define VPI(name,size) vc<pi> name(size);rep(i_##name,size)input(name[i_##name]);
#define VVI(name,sizeN,sizeM) vvi name(sizeN,vi(sizeM));\
rep(i_##name,sizeN)rep(j_##name,sizeM)input(name[i_##name][j_##name]);
#define VS(name,size) vc<string> name(size);rep(i_##name,size)input(name[i_##name]);

#define overload5(a,b,c,d,e,f,...) f
#define VVC4(type,name,sizeN,sizeM) vvc<type> name(sizeN,vc<type>(sizeM));
#define VVC5(type,name,sizeN,sizeM,ini) vvc<type> name(sizeN,vc<type>(sizeM,ini));
#define VVC(...) overload5(__VA_ARGS__,VVC5,VVC4)(__VA_ARGS__)

template<class T>
T vvvc(T v){
	return v;
}

template<class T,class...Args>
auto vvvc(int n,T v,Args...args){
	return vector(n,vvvc(v,args...));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

void printsuc(int suc){
	if(suc==1){
		if(dbg)cout<<endl;
		else{
			#ifdef LOCAL
			cout<<endl;
			#else
			cout<<"\n";
			#endif
		}
	}
	if(suc==2)
		cout<<" ";
}

template<class t>
void print_single(t x,int suc=1){
	cout<<x;
	printsuc(suc);
}

template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
	print_single(p.a,2);
	print_single(p.b,suc);
}

template<class T>
void print_single(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print_single(v[i],i==int(v.size())-1?3:2);
	printsuc(suc);
}

template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
	rep(i,N)
		print_single(v[i],i==int(N)-1?3:2);
	printsuc(suc);
}

template<class T>
void print(const T&t){
	print_single(t);
}

template<class T,class ...Args>
void print(const T&t,const Args&...args){
	print_single(t,2);
	print(args...);
}

template<class T>
void printvv(const vvc<T>&vs){
	for(const auto&row:vs)print(row);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}*/
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
int popcount(ull t){
	return __builtin_popcountll(t);
}
int bitparity(ll t){
	return __builtin_parityll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}
ull umask(int i){
	return (ull(1)<<i)-1;
}
ll minp2(ll n){
	if(n<=1)return 1;
	else return ll(1)<<(topbit(n-1)+1);
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class S> void mkuni(S&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

template<class t> bool isuni(vc<t> v){
	int s=si(v);
	mkuni(v);
	return si(v)==s;
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class S,class u>
int lwb(const S&v,const u&a){
	return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
	return binary_search(all(v),a);
}

//VERIFY: yosupo
//KUPC2017J
//AOJDSL1A
//without rank
struct unionfind{
	vi p,s;
	int c;
	unionfind(int n):p(n,-1),s(n,1),c(n){}
	void clear(){
		fill(all(p),-1);
		fill(all(s),1);
		c=si(p);
	}
	int find(int a){
		return p[a]==-1?a:(p[a]=find(p[a]));
	}
	//set b to a child of a
	bool unite(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b)return false;
		p[b]=a;
		s[a]+=s[b];
		c--;
		return true;
	}
	bool same(int a,int b){
		return find(a)==find(b);
	}
	int sz(int a){
		return s[find(a)];
	}
};

vvc<int> readGraph(int n,int m){
	vvc<int> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		//sc.read(a,b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	return g;
}

vvc<int> rand_tree(int n){
	vvc<int> t(n);
	unionfind uf(n);
	while(uf.c>1){
		int a=rand_int(n);
		int b=rand_int(n);
		if(uf.unite(a,b)){
			t[a].pb(b);
			t[b].pb(a);
		}
	}
	return t;
}

vvc<int> readTree(int n){
	if(dbg){
		return rand_tree(n);
	}else{
		return readGraph(n,n-1);
	}
}

vi readRooted(int n){
	assert(!dbg);
	vi par(n,-1);
	rng(i,1,n){
		input(par[i]);
		par[i]--;
		assert(inc(0,par[i],i-1));
	}
	return par;
}

void printTree(const vvc<int> t){
	int n=si(t);
	int degsum=0;
	rep(i,n)degsum+=si(t[i]);
	if(degsum==n-1){
		//directed
		rep(i,si(t))for(auto j:t[i]){
			print(i+1,j+1);
		}
	}else if(degsum==2*(n-1)){
		//undirected
		rep(i,si(t))for(auto j:t[i])if(i<j){
			print(i+1,j+1);
		}
	}else{
		assert(false);
	}
}

template<class t>
vc<t> presum(const vc<t>&a){
	vc<t> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
vc<ll> presum(const vi&a){
	vc<ll> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
	gnr(i,1,si(a))a[i]-=a[i-1];
	return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
	int n=si(a),m=si(a[0]);
	vvc<ll> b(n+1,vc<ll>(m+1));
	rep(i,n)rep(j,m)
		b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
	return b;
}

//verify してないや
void transvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[j][i]=a[i][j];
	}
	a.swap(b);
	transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[m-1-j][i]=a[i][j];
	}
	a.swap(b);
	rotvvc(n,m,args...);
}

//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
	int n=si(a);
	vi idx(n);iota(all(idx),0);
	sort(all(idx),[&](int i,int j){return a[i]<a[j];});
	return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
	int n=si(a);
	assert(si(idx)==n);
	vc<t> vs(n);
	rep(i,n)vs[i]=a[idx[i]];
	return vs;
}
//CF850C
vi invperm(const vi&p){
	int n=si(p);
	vi q(n);
	rep(i,n)q[p[i]]=i;
	return q;
}

template<class t,class s=t>
s SUM(const vc<t>&a){
	return accumulate(all(a),s(0));
}
template<class t,size_t K,class s=t>
s SUM(const array<t,K>&a){
	return accumulate(all(a),s(0));
}

template<class t>
t MAX(const vc<t>&a){
	return *max_element(all(a));
}

template<class t>
pair<t,int> MAXi(const vc<t>&a){
	auto itr=max_element(all(a));
	return mp(*itr,itr-a.bg);
}

template<class A>
auto MIN(const A&a){
	return *min_element(all(a));
}

template<class t>
pair<t,int> MINi(const vc<t>&a){
	auto itr=min_element(all(a));
	return mp(*itr,itr-a.bg);
}

vi vid(int n){
	vi res(n);iota(all(res),0);
	return res;
}

template<class S>
void soin(S&s){
	sort(all(s));
}

template<class S,class F>
void soin(S&s,F&&f){
	sort(all(s),forward<F>(f));
}

template<class S>
S soout(S s){
	soin(s);
	return s;
}

template<class S>
void rein(S&s){
	reverse(all(s));
}

template<class S>
S reout(S s){
	rein(s);
	return s;
}

template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
	a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
	a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}
template<class t,class u,class v>
pair<t,u>&operator*=(pair<t,u>&a,v b){
	a.a*=b;a.b*=b;return a;}
template<class t,class u,class v>
pair<t,u> operator*(pair<t,u> a,v b){return a*=b;}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a){return mp(-a.a,-a.b);}
namespace std{
template<class t,class u>
istream&operator>>(istream&is,pair<t,u>&a){
	return is>>a.a>>a.b;
}
}

template<class t>
t gpp(vc<t>&vs){
	assert(si(vs));
	t res=move(vs.back());
	vs.pop_back();
	return res;
}

template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
	a.insert(a.ed,all(b));
}

template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
	(pb(a,forward<Args>(b)),...);
	return a;
}

template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
	for(auto&v:a)v+=x;
	return a;
}

template<class t,class u>
vc<t> operator+(vc<t> a,u x){
	return a+=x;
}

template<class t>
vc<t>& operator+=(vc<t>&a,const vc<t>&b){
	a.resize(max(si(a),si(b)));
	rep(i,si(b))a[i]+=b[i];
	return a;
}

template<class t>
vc<t> operator+(const vc<t>&a,const vc<t>&b){
	vc<t> c(max(si(a),si(b)));
	rep(i,si(a))c[i]+=a[i];
	rep(i,si(b))c[i]+=b[i];
	return c;
}

template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
	for(auto&v:a)v-=x;
	return a;
}
template<class t,class u>
vc<t> operator-(vc<t> a,u x){
	return a-=x;
}

template<class t,class u>
vc<t>& operator*=(vc<t>&a,u x){
	for(auto&v:a)v*=x;
	return a;
}
template<class t,class u>
vc<t> operator*(vc<t> a,u x){
	return a*=x;
}

template<class t,class u>
vc<t>& operator/=(vc<t>&a,u x){
	for(auto&v:a)v/=x;
	return a;
}
template<class t,class u>
vc<t> operator/(vc<t> a,u x){
	return a/=x;
}

template<class t>
vc<t>& operator<<=(vc<t>&a,int k){
	assert(k>=0);
	a.insert(a.bg,k,t(0));
	return a;
}
template<class t>
vc<t> operator<<(vc<t> a,int k){
	return a<<=k;
}

template<class t>
vc<t>& operator>>=(vc<t>&a,int k){
	if(si(a)<=k)a.clear();
	else a.erase(a.bg,a.bg+k);
	return a;
}
template<class t>
vc<t> operator>>(vc<t> a,int k){
	return a>>=k;
}

template<class t,class u>
void remval(vc<t>&a,const u&v){
	a.erase(remove(all(a),v),a.ed);
}
//消した要素の個数を返してくれる
//UCUP 2-8-F
template<class t,class F>
int remif(vc<t>&a,F f){
	auto itr=remove_if(all(a),f);
	int res=a.ed-itr;
	a.erase(itr,a.ed);
	return res;
}
template<class t>
void rempos(vc<t>&a,int i){
	assert(inc(0,i,si(a)-1));
	a.erase(a.bg+i);
}

template<class VS,class u>
void fila(VS&vs,const u&a){
	fill(all(vs),a);
}

template<class t,class u>
int findid(const vc<t>&vs,const u&a){
	auto itr=find(all(vs),a);
	if(itr==vs.ed)return -1;
	else return itr-vs.bg;
}

template<class t>
void rtt(vc<t>&vs,int i){
	rotate(vs.bg,vs.bg+i,vs.ed);
}

//Multiuni2023-8 C
//f(lw)=false,...,f(n-1)=false,f(n)=true,...,f(up)=true,
//のときに n を返す
template<class F>
int find_min_true(int lw,int up,F f){
	while(up-lw>1){
		const int mid=(lw+up)/2;
		if(f(mid))up=mid;
		else lw=mid;
	}
	return up;
}
//f(lw)=true,f(up)=false
template<class F>
int find_max_true(int lw,int up,F f){
	while(up-lw>1){
		const int mid=(lw+up)/2;
		if(f(mid))lw=mid;
		else up=mid;
	}
	return lw;
}

template<class t> using pqmin=priority_queue<t,vc<t>,greater<t>>;
template<class t> using pqmax=priority_queue<t>;
using T=tuple<int,int,int>;

//mint107 は verify してねえ
#define DYNAMIC_MOD

struct modinfo{uint mod,root;
#ifdef DYNAMIC_MOD
constexpr modinfo(uint m,uint r):mod(m),root(r),im(0){set_mod(m);}
ull im;
constexpr void set_mod(uint m){
	mod=m;
	im=ull(-1)/m+1;
}
uint product(uint a,uint b)const{
	ull z=ull(a)*b;
	uint x=((unsigned __int128)z*im)>>64;
	uint v=uint(z)-x*mod;
	return v<mod?v:v+mod;
}
#endif
};
template<modinfo const&ref>
struct modular{
	static constexpr uint const &mod=ref.mod;
	static modular root(){return modular(ref.root);}
	uint v;
	//modular(initializer_list<uint>ls):v(*ls.bg){}
	modular(ll vv=0){s(vv%mod+mod);}
	modular& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	modular operator-()const{return modular()-*this;}
	modular& operator+=(const modular&rhs){return s(v+rhs.v);}
	modular&operator-=(const modular&rhs){return s(v+mod-rhs.v);}
	modular&operator*=(const modular&rhs){
		#ifndef DYNAMIC_MOD
		v=ull(v)*rhs.v%mod;
		#else
		v=ref.product(v,rhs.v);
		#endif
		return *this;
	}
	modular&operator/=(const modular&rhs){return *this*=rhs.inv();}
	modular operator+(const modular&rhs)const{return modular(*this)+=rhs;}
	modular operator-(const modular&rhs)const{return modular(*this)-=rhs;}
	modular operator*(const modular&rhs)const{return modular(*this)*=rhs;}
	modular operator/(const modular&rhs)const{return modular(*this)/=rhs;}
	modular pow(ll n)const{
		if(n<0)return inv().pow(-n);
		modular res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	modular inv()const{return pow(mod-2);}
	/*modular inv()const{
		int x,y;
		int g=extgcd<ll>(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return modular(x);
	}*/
	friend modular operator+(ll x,const modular&y){
		return modular(x)+y;
	}
	friend modular operator-(ll x,const modular&y){
		return modular(x)-y;
	}
	friend modular operator*(ll x,const modular&y){
		return modular(x)*y;
	}
	friend modular operator/(ll x,const modular&y){
		return modular(x)/y;
	}
	friend ostream& operator<<(ostream&os,const modular&m){
		return os<<m.v;
	}
	friend istream& operator>>(istream&is,modular&m){
		ll x;is>>x;
		m=modular(x);
		return is;
	}
	bool operator<(const modular&r)const{return v<r.v;}
	bool operator==(const modular&r)const{return v==r.v;}
	bool operator!=(const modular&r)const{return v!=r.v;}
	explicit operator bool()const{
		return v;
	}
};

#ifndef DYNAMIC_MOD
extern constexpr modinfo base{998244353,3};
//extern constexpr modinfo base{1000000007,0};
//extern constexpr modinfo base{2147483579,1689685080};//2^31 未満の最大の安全素数
//modinfo base{1,0};
#ifdef USE_GOOD_MOD
static_assert(base.mod==998244353);
#endif
#else
modinfo base(1,0);
extern constexpr modinfo base107(1000000007,0);
using mint107=modular<base107>;
#endif
using mint=modular<base>;

mint parity(int i){
	return i%2==0?1:-1;
}

pi m2f(mint x){
	pi res(inf,inf);
	auto upd=[&](int a,int b){
		if(abs(res.a)+res.b>abs(a)+b){
			res=pi(a,b);
		}
	};
	rng(b,1,1000){
		mint y=x*b;
		upd(y.v,b);
		upd(-int((-y).v),b);
	}
	return res;
}

mint work(int k){
	if(k<2)return 0;
	static map<int,mint> memo;
	if(memo.contains(k))return memo[k];
	mint ans=1,cur=1;
	gnr(v,1,k-2+1){
		cur*=v;
		ans+=cur;
	}
	return memo[k]=ans;
}

void slv(){
	INT(n,m,q,S);
	base.set_mod(S);
	
	vvc<int> g(n);
	rep(_,m){
		INT(u,v);
		g[u].pb(v);
	}
	rep(i,n)soin(g[i]);
	
	unionfind uf(n);
	vi kind(n);
	{
		auto dfs=[&](auto self,int v)->void{
			if(kind[v]!=0)return;
			kind[v]=1;
			for(auto to:g[v]){
				uf.unite(v,to);
				self(self,to);
			}
		};
		rep(i,n)if(si(g[i])>=2){
			for(auto j:g[i]){
				dfs(dfs,j);
				uf.unite(g[i][0],j);
			}
		}
	}
	
	{
		vi c(n);
		rep(i,n){
			for(auto j:g[i])c[j]++;
		}
		vi ls;
		rep(i,n)if(kind[i]==0&&c[i]==0)
			ls.pb(i);
		int j=0;
		while(j<int(ls.size())){
			int i=ls[j++];
			kind[i]=2;
			for(auto to:g[i]){
				if(--c[to]==0&&kind[to]==0){
					ls.pb(to);
				}
			}
		}
	}
	rep(i,n)for(auto j:g[i])if(kind[i]==kind[j])uf.unite(i,j);
	
	vi in(n,-1),out(n,-1),root(n,-1);
	{
		vvc<int> t(n);
		rep(i,n)if(kind[i]==2)for(auto j:g[i])if(kind[j]==2)
			t[j].pb(i);
		int head=0;
		auto dfs=[&](auto self,int v,int r)->void{
			in[v]=head++;
			root[v]=r;
			for(auto ch:t[v]){
				self(self,ch,r);
			}
			out[v]=head;
		};
		rep(i,n)if(kind[i]==2){
			bool ok=true;
			for(auto j:g[i])if(kind[j]==2)ok=false;
			if(ok){
				dfs(dfs,i,i);
			}
		}
	}
	
	rep(_,q){
		INT(u,v);
		mint ans;
		if(u==v)ans=1;
		else{
			if(kind[v]==0){
				if(kind[u]==0){
					ans=uf.same(u,v);
				}else if(kind[u]==1){
					ans=0;
				}else{
					u=root[u];
					if(si(g[u]))u=g[u][0];
					ans=uf.same(u,v);
				}
			}else if(kind[v]==1){
				if(kind[u]==0){
					ans=0;
				}else if(kind[u]==1){
					ans=work(uf.sz(u));
				}else{
					u=root[u];
					if(si(g[u])&&uf.same(g[u][0],v)){
						int d=si(g[u]);
						if(bis(g[u],v)){
							ans+=1;
							d--;
						}
						ans+=work(uf.sz(v))*d;
					}
				}
			}else{
				if(kind[u]==0){
					ans=0;
				}else if(kind[u]==1){
					ans=0;
				}else{
					dmp2(_,in[v],out[v],in[u],out[u]);
					ans=(in[v]<=in[u]&&out[u]<=out[v]);
				}
			}
		}
		
		print(ans);
	}
}

signed main(signed argc,char*argv[]){
	if(argc>1&&strcmp(argv[1],"D")==0)dbg=true;
	
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	if(dbg){
		while(1){
			if(current_run_id%run_batch_size==0){
				cerr<<"Current Run "<<current_run_id<<endl;
			}
			slv();
			current_run_id++;
		}
	}else{
		//int t;cin>>t;rep(_,t)
		slv();
	}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

input:

11 9 30 998244353
0 1
0 2
3 4
5 4
6 5
7 8
8 9
9 8
10 9
0 1
0 2
1 0
1 2
2 0
2 1
3 4
3 5
3 6
4 3
4 5
4 6
5 3
5 4
5 6
6 3
6 4
6 5
7 8
7 9
7 10
8 7
8 9
8 10
9 7
9 8
9 10
10 7
10 8
10 9

output:

2
2
0
1
0
1
1
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
1
0
0
1
0
0
1
1

result:

ok 30 numbers

Test #2:

score: 0
Accepted
time: 485ms
memory: 62192kb

input:

490330 975088 999910 1
348838 147909
295660 265201
357515 214814
100870 359366
408255 86356
60134 169442
409736 191593
231830 141232
197635 250005
4728 186530
38142 185732
95910 109149
239818 295107
421484 92342
121513 336128
101868 288271
59786 95719
139655 36705
360745 150735
256350 279669
262586 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 999910 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

10 10 100 763034674
7 0
0 2
3 8
6 0
1 3
9 2
6 9
5 6
9 5
3 4
8 1
0 7
8 4
3 8
3 8
3 8
2 5
7 9
3 4
7 5
2 0
4 8
7 9
8 8
0 7
9 5
2 5
9 0
0 7
8 4
8 4
8 4
5 5
5 5
0 0
9 9
5 6
0 9
3 4
4 8
9 9
6 6
8 4
4 4
4 8
2 6
4 8
5 0
8 8
8 4
0 0
0 6
4 4
8 8
4 8
5 0
4 8
6 0
0 2
6 2
2 0
8 4
6 2
9 6
7 5
2 0
4 8
2 6
0 7
4 8
...

output:

0
0
1
2
2
2
16
16
2
16
16
1
16
1
0
16
16
16
0
1
1
1
1
1
1
1
16
16
2
1
1
1
1
1
1
16
1
16
1
1
1
16
1
1
1
16
1
16
16
16
16
1
16
16
16
16
1
16
0
1
1
0
0
16
0
1
16
16
1
2
1
16
16
16
16
16
16
16
1
1
1
16
1
0
1
16
0
0
1
2
16
1
16
1
16
16
1
1
1
16

result:

ok 100 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

50 10 100 1070103429
28 3
8 26
19 38
8 40
20 16
43 21
38 45
10 38
9 19
6 20
24 19
27 15
31 19
46 24
10 13
16 16
34 6
38 10
18 11
3 10
12 29
1 8
11 10
26 26
8 40
24 24
48 16
14 14
1 1
26 8
32 11
20 41
47 11
38 15
40 40
26 26
48 48
32 47
17 5
5 17
47 15
25 3
42 4
7 33
26 40
2 28
8 8
19 43
35 35
3 28
2...

output:

0
0
0
0
0
1
0
0
0
0
0
0
0
1
2
1
0
1
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
1
0

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 24ms
memory: 14516kb

input:

99623 99623 100 980056881
50757 25203
99537 20492
33371 48876
52806 45345
61275 47516
65451 17847
65373 46852
78376 33830
15634 28406
36474 5662
91602 42311
90137 24445
33553 21087
59721 93957
36579 74850
54390 19053
69864 7358
78013 64007
14171 43359
57967 60175
92077 85491
7703 69112
43990 24704
7...

output:

0
1
1
1
1
1
1
1
0
0
1
1
1
1
0
1
0
0
1
1
0
1
1
0
1
0
0
1
0
0
1
0
0
1
0
1
0
1
0
1
1
0
0
0
1
1
0
0
1
0
0
0
1
0
1
1
1
1
0
1
1
0
1
0
1
1
1
1
1
1
0
1
1
1
0
0
1
1
0
1
0
0
1
1
1
1
1
1
1
1
0
1
1
1
0
1
0
0
1
1

result:

ok 100 numbers

Test #6:

score: 0
Accepted
time: 41ms
memory: 14780kb

input:

99918 99918 99998 1022622503
96115 4311
29079 39829
20182 38885
37901 97478
86725 29612
11613 64460
42977 40665
40871 91372
47278 98928
58637 90652
5876 906
93188 99769
93389 85948
82898 6955
50967 30929
28835 31296
97643 231
32832 27254
1524 64074
99349 86599
29210 75922
36883 12162
72002 43881
337...

output:

1
1
1
1
1
0
1
0
0
1
1
0
1
1
0
1
1
0
1
1
0
1
1
0
0
0
1
0
1
0
1
0
1
1
0
0
1
1
1
1
1
1
0
1
0
1
1
1
0
0
0
0
0
1
0
1
1
1
0
0
1
0
0
1
0
1
0
1
0
1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
1
1
1
0
1
1
1
1
0
0
1
1
1
0
0
0
1
0
1
1
1
1
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
0
1
1
0
0
0
1
1
0
0
1
0
1
1
1
1
1
1
0
1
0
1
0
1
1
0
1
1
...

result:

ok 99998 numbers

Test #7:

score: 0
Accepted
time: 27ms
memory: 14536kb

input:

99400 99058 100 899083628
39194 29750
54542 38986
59905 14414
15149 97934
34222 83755
57222 15382
72075 71746
90174 46964
79135 84263
92426 7282
91385 2634
24502 61087
25413 52486
62136 41629
7136 39660
81877 38747
3061 24370
90906 16423
207 19272
87998 60759
18593 96794
80669 81733
75533 16976
485 ...

output:

0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
1

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 44ms
memory: 14396kb

input:

99807 99447 99956 941649250
42782 17404
35582 96091
72688 43027
21150 28696
44587 19242
10867 78364
57479 62174
45656 61379
43003 45141
38184 12324
30085 1034
21751 4852
95368 97879
81655 55976
16200 89877
14629 28416
38024 84785
25925 5010
83369 71309
1344 39538
41803 6442
93767 98088
22791 57130
8...

output:

0
1
0
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
0
0
1
0
0
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
...

result:

ok 99956 numbers

Test #9:

score: 0
Accepted
time: 2ms
memory: 4072kb

input:

992 9880 1000 70378016
984 617
323 892
290 802
696 738
804 155
917 96
973 838
312 821
34 424
163 886
240 177
323 874
450 301
576 426
817 534
125 566
888 942
287 379
20 94
925 276
328 169
942 186
57 316
516 276
904 100
410 443
138 802
281 575
333 750
110 671
12 496
320 147
823 316
599 422
176 377
814...

output:

40082542
40082542
40082542
40082542
40082542
40082542
40082542
0
40082542
40082542
40082542
40082542
40082542
40082542
9787068
40082542
40082542
9787068
40082542
40082542
40082542
0
40082542
40082542
40082542
40082542
40082542
40082542
9787068
40082542
9787068
9787068
0
40082542
40082542
9787068
400...

result:

ok 1000 numbers

Test #10:

score: 0
Accepted
time: 153ms
memory: 21372kb

input:

99676 908027 99980 1000000007
92287 84609
40789 2997
11339 38071
79348 89212
42723 18039
25086 14630
15002 48454
74156 31809
81099 672
58820 34204
42380 54992
72471 67280
22513 68145
97886 53222
67440 52761
67792 40482
24643 63912
59981 33502
20889 28561
12601 33295
33170 80694
25860 75071
26068 133...

output:

0
342735715
685471430
342735715
342735715
342735715
342735715
342735715
342735715
342735715
342735715
342735715
342735715
342735715
342735715
685471430
342735715
342735715
342735715
342735715
342735715
342735715
342735715
685471430
342735715
685471430
0
342735715
342735715
342735715
342735715
685471...

result:

ok 99980 numbers

Test #11:

score: 0
Accepted
time: 152ms
memory: 21280kb

input:

99789 898898 99973 32768
42078 85396
15054 67134
89810 91885
87478 52236
21048 73176
34479 45280
93216 34925
88837 19731
76320 26821
91959 35476
16308 59346
8908 46903
35281 14813
4235 92734
72386 27559
50218 41931
63955 27911
20524 27576
40858 6747
74421 31142
61926 35049
211 18147
64263 69457
1571...

output:

11082
5541
11082
5541
5541
5541
5541
11082
5541
5541
5541
5541
5541
5541
5541
5541
5541
5541
0
5541
5541
5541
5541
5541
5541
5541
11082
5541
5541
5541
5541
5541
5541
5541
5541
5541
11082
5541
5541
5541
0
11082
5541
5541
5541
5541
5541
5541
5541
5541
5541
5541
5541
5541
0
5541
5541
5541
5541
5541
554...

result:

ok 99973 numbers

Test #12:

score: 0
Accepted
time: 158ms
memory: 20952kb

input:

99664 898556 99986 860675994
85253 55130
3111 14635
18732 59278
60532 11464
48288 99546
71199 30046
14561 63310
15653 3752
3912 97856
3705 50910
42674 10971
88351 92992
19700 42674
17139 21949
16140 64530
79106 26601
9790 57294
76311 59462
87545 68991
3756 52301
47331 77521
8284 6947
80386 33961
261...

output:

576248876
576248876
576248876
576248876
576248876
576248876
576248876
576248876
0
576248876
576248876
576248876
576248876
576248876
576248876
576248876
576248876
576248876
576248876
576248876
291821758
0
291821758
576248876
291821758
0
576248876
576248876
576248876
576248876
0
576248876
576248876
57...

result:

ok 99986 numbers

Test #13:

score: 0
Accepted
time: 2ms
memory: 3752kb

input:

1000 9987 1000 1063146582
213 864
870 590
759 470
277 590
940 972
117 115
133 385
561 277
333 253
539 805
720 220
193 818
794 225
851 136
333 87
488 829
31 481
768 73
739 529
905 794
124 195
174 805
529 595
81 431
81 233
713 999
652 768
385 485
636 812
475 758
81 529
799 195
759 535
744 975
209 394
...

output:

446156645
89231329
89231329
446156645
89231329
907572022
89231329
446156645
1
0
1
0
89231329
0
89231329
89231329
1
89231329
1
1
907572022
0
89231329
1
0
1
89231329
89231329
1
0
89231329
89231329
89231329
1
446156645
0
1
446156645
1
1
89231329
89231329
1
0
446156645
89231329
89231329
1
0
0
0
0
892313...

result:

ok 1000 numbers

Test #14:

score: 0
Accepted
time: 147ms
memory: 19400kb

input:

99961 815966 99991 19683
28582 16563
15302 50712
61184 5163
22446 21775
78337 12895
43968 16679
87757 140
15367 29739
84067 16016
62557 65137
38670 80599
9548 34969
96285 55127
61588 1732
29351 13191
39945 16016
40103 15748
96767 48885
62341 79520
47488 23205
91177 18442
69914 6305
15023 42307
43039...

output:

12060
2829
0
0
16085
0
18924
18502
2830
0
2830
0
0
2035
0
10502
0
0
0
0
0
5247
12060
0
0
0
0
16085
13256
16930
0
2035
18924
5669
0
0
0
16085
0
16085
18924
0
0
0
0
0
18924
12060
16085
0
14060
16085
12060
0
0
18924
0
0
0
0
16085
0
0
12060
0
0
0
14080
16085
0
16085
0
0
16085
0
16930
0
0
0
0
16085
0
0
1...

result:

ok 99991 numbers

Test #15:

score: 0
Accepted
time: 140ms
memory: 19824kb

input:

99462 813007 99992 779702741
37081 12978
57353 64379
85797 164
1520 86507
84134 10450
81061 4901
91664 12347
28028 97732
13558 1222
96104 90535
73047 58083
84350 58856
57411 70765
12160 59380
34674 55254
81566 18238
76503 47810
44994 87776
84294 1664
2142 74766
58209 16327
25833 95289
43553 14681
63...

output:

504392388
311179206
713599917
306961279
0
713599917
0
0
0
0
1
0
0
0
0
343707493
713599917
0
0
480131069
282699960
0
335440525
0
0
0
0
335440525
0
0
755441423
317860336
311179206
317860336
311179206
0
0
311179206
0
0
0
311179206
0
317860336
0
317860336
311179206
306961279
311179206
0
0
282699960
1
0
...

result:

ok 99992 numbers

Test #16:

score: 0
Accepted
time: 106ms
memory: 8548kb

input:

9890 771347 100000 10007
1807 8193
7832 7478
8096 4467
8382 6002
9571 4866
2460 7389
8922 3733
2965 14
3122 2206
5592 1550
8015 589
8015 8284
9570 6326
5207 3284
7986 2291
3388 1677
7252 6891
8551 890
8328 8284
6327 5277
3251 2335
5276 5622
618 9398
5660 9661
9676 7551
5456 9523
1073 4454
4200 2785
...

output:

0
4049
1602
4049
1370
1602
5933
7965
1370
1602
1370
3395
6897
0
435
5933
4049
1370
0
9400
3395
1602
8812
1602
4049
8812
9400
4049
0
4049
0
0
1370
0
3138
4049
0
0
6897
4049
6607
2922
6607
6607
1602
9400
1112
0
3138
1602
1370
9400
9400
5530
1602
1602
0
9400
0
2922
5530
0
0
7982
3395
9400
6607
6897
0
0...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 133ms
memory: 17484kb

input:

99811 699197 99991 15625
86625 59478
20812 76888
55859 93386
17571 93823
20330 56315
41644 68214
64293 51049
49283 7151
16866 65744
7510 4546
13611 52692
86190 30703
12972 62703
54411 67707
74890 78525
16683 47000
9696 53982
49693 26011
30180 49236
44952 96435
41946 96670
99398 8212
1457 18086
50058...

output:

0
6865
2501
0
3870
9835
2765
9835
13695
0
0
13655
0
0
13695
13695
0
11465
0
194
1830
11080
0
1245
4621
12851
0
0
9338
890
0
0
0
3940
1
0
0
11346
11346
0
0
13695
0
0
2765
13570
13860
0
0
2377
5030
0
0
0
0
0
0
194
1
0
0
890
9835
6865
0
0
6831
1103
13695
7415
3391
1842
0
0
0
5030
4621
0
14920
0
0
0
0
0...

result:

ok 99991 numbers

Test #18:

score: 0
Accepted
time: 453ms
memory: 61672kb

input:

497874 982381 999937 1000000009
213037 19051
434410 167830
97789 439284
118053 294932
445258 186947
42988 89834
445703 168088
359863 390501
147993 224527
61303 136397
134286 301377
306820 226022
305074 461583
394818 410890
479262 256077
212167 410479
121597 331240
407580 342240
118032 435057
402915 ...

output:

354442583
0
0
0
0
1
935377062
49487291
0
354442583
0
0
999239563
999239563
354442583
0
0
0
0
0
0
0
0
399512194
0
0
714160876
496968815
231209613
213172207
0
0
0
0
0
0
1
0
846168135
0
154118383
0
0
0
904720298
744498487
655421219
324180828
0
744498487
0
27777530
744498487
0
201687494
0
231209613
8407...

result:

ok 999937 numbers

Test #19:

score: 0
Accepted
time: 494ms
memory: 64032kb

input:

494830 885706 999958 2401
124692 425460
122070 362854
210240 452328
240245 279078
376495 397976
77586 253505
280732 186356
149244 146584
462101 422526
268812 365792
400507 140426
10445 358775
194169 492348
325454 33248
252000 79290
51412 36781
387850 452871
481401 348596
11068 203053
91484 287059
16...

output:

0
111
51
757
0
0
0
0
22
0
0
63
379
1878
0
0
1
0
1
0
1878
0
1850
1
2329
102
1657
1
0
1142
0
0
0
380
0
1332
1
0
0
0
0
0
0
0
325
0
0
1
1
757
757
2350
0
0
577
0
0
0
0
1575
0
0
0
1850
1
11
0
0
0
1290
0
760
1
0
1
0
1663
0
0
1
1896
11
1
0
0
0
757
0
0
189
505
1012
1682
0
0
63
757
0
1
1
1012
954
0
0
2329
0
6...

result:

ok 999958 numbers

Test #20:

score: 0
Accepted
time: 113ms
memory: 3868kb

input:

70 0 999815 736939200
28 15
12 40
66 66
68 60
59 16
41 41
52 1
31 31
40 19
13 51
31 14
58 42
61 34
56 25
63 63
50 11
36 67
12 12
58 55
0 19
21 55
46 46
67 8
28 25
25 50
9 69
55 42
51 46
7 7
7 59
66 14
60 60
40 65
13 34
52 52
23 39
38 43
67 10
35 52
66 47
25 25
14 50
44 23
21 21
19 19
45 1
32 35
64 6...

output:

0
0
1
0
0
1
0
1
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
1
0
1
1
1
0
0
0
1
0
0
1
1
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
1
0
1
0
1
0
0
1
0
0
0
0
0
1
0
0
1
1
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
1
0
...

result:

ok 999815 numbers

Extra Test:

score: 0
Extra Test Passed