QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#815417#9875. Don't Detect Cycleucup-team087#AC ✓1243ms5208kbC++2319.8kb2024-12-15 14:07:502024-12-15 14:07:50

Judging History

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

  • [2024-12-15 14:07:50]
  • 评测
  • 测评结果:AC
  • 用时:1243ms
  • 内存:5208kb
  • [2024-12-15 14:07:50]
  • 提交

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{
		#ifdef USE_FAST_IO
		sc.read(a...);
		#else
		(cin >> ... >> a);
		#endif
	}
}
#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].a,name[i_##name].b);
#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 VMI(name,size) vc<mint> name(size);rep(i_##name,size){INT(tmp_##name);name[i_##name]=tmp_##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){
	#ifdef USE_FAST_IO
		if(suc==1)pr.write('\n');
		if(suc==2)pr.write(' ');
	#else
		if(suc==1){
			if(dbg)cout<<endl;
			else{
				#ifdef LOCAL
				cout<<endl;
				#else
				cout<<"\n";
				#endif
			}
		}
		if(suc==2)
			cout<<" ";
	#endif
}

template<class t>
void print_single(t x,int suc=1){
	#ifdef USE_FAST_IO
	pr.write(x);
	#else
	cout<<x;
	#endif
	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,size_t n>
array<t,n>&operator+=(array<t,n>&a,const array<t,n>&b){
	rep(i,n)a[i]+=b[i];
	return a;
}
template<class t,size_t n,class v>
array<t,n>&operator*=(array<t,n>&a,v b){
	rep(i,n)a[i]*=b;
	return a;
}
template<class t,size_t n,class v>
array<t,n> operator*(array<t,n> a,v b){return 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>
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>
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>;

//連結成分と頂点を一緒くたにした場合の木が tr で得られる
//連結成分たくさんとか多重辺ありとかでも動くはずだが,未確認
//連結成分 x の頂点リスト -> tr[n+x]
//孤立点は連結成分として処理されない
//s に biconnected components の個数が入る
//es にその biconnected componenents の辺のリストが入る
//辺の端点はもともとのグラフの頂点番号を使う
//VERIFY
//Petrozavodsk Camp 2020S Day2 C
//TCO2020 Wildcard Hard
//CF CodeTON Round I
//UCUP3-3-L cactus のとき tr の頂点は cactus のサイクル順に並んでいて便利
template<class E>
struct articulation{
	const int n;
	const vvc<E>&g;
	vi vis,ord,low;
	int head,s;
	vvc<int> tr;
	vvc<pi> es;
	void ae(int a,int b){
		if(a==-1||b==-1)return;
		tr[a].pb(b);
		tr[b].pb(a);
	}
	void dfs(int v){
		assert(vis[v]==0);
		vis[v]=1;
		ord[v]=low[v]=head++;
		for(auto to:g[v]){
			if(vis[to]==0){
				dfs(to);
				chmin(low[v],low[to]);
			}else{
				chmin(low[v],ord[to]);
			}
		}
	}
	void dfs2(int v,int z){
		assert(vis[v]==1);
		vis[v]=2;
		ae(v,z);
		for(auto to:g[v])if(vis[to]==1){
			if(low[to]<ord[v]){
				dfs2(to,z);
			}else{
				int w=si(tr);
				tr.eb();
				es.eb();
				s++;
				ae(v,w);
				dfs2(to,w);
			}
		}else if(vis[to]==2){
			es[z-n].eb(v,to);
		}
		vis[v]=3;
	}
	articulation(const vvc<E>&gg):n(si(gg)),g(gg),
		vis(n,0),ord(n,-1),low(n,-1),head(0),s(0),tr(n){
		rep(i,n)if(vis[i]==0){
			dfs(i);
			dfs2(i,-1);
		}
	}
	//連結成分 i の辺情報を頂点番号を座標圧縮した上で返す
	pair<vi,vc<pi>> getg(int i){
		vi vs=tr[n+i];
		sort(all(vs));
		vc<pi> res=es[i];
		for(auto&[a,b]:res){
			a=lwb(vs,a);
			b=lwb(vs,b);
		}
		return mp(vs,res);
	}
};

void slv(){
	INT(n,m);
	VPI(es,m);
	for(auto&[a,b]:es){
		a--;b--;
	}
	map<pi,int> lookup;
	rep(i,m){
		lookup[es[i]]=i;
		lookup[pi(es[i].b,es[i].a)]=i;
	}
	
	vc<bool> avail(m,true);
	vvc<int> g(n);
	vi ans(m,-1);
	per(step,m){
		rep(i,n)g[i].clear();
		rep(i,m)if(avail[i]){
			auto [a,b]=es[i];
			g[a].pb(b);
			g[b].pb(a);
		}
		articulation<int> art(g);
		pi f(-1,-1);
		rep(i,art.s){
			for(auto [a,b]:art.es[i]){
				if(si(art.tr[n+i])==2){
					if(si(g[a])==si(art.tr[a])&&si(g[b])==si(art.tr[b])){
						f=pi(a,b);
					}
				}else{
					if(si(g[a])==si(art.tr[a])+1&&si(g[b])==si(art.tr[b])+1){
						f=pi(a,b);
					}
				}
			}
		}
		if(f==pi(-1,-1)){
			return print(-1);
		}
		int u=lookup[f];
		avail[u]=false;
		ans[step]=u;
	}
	print(ans+1);
}

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,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3552kb

input:

1
4 4
1 2
2 3
3 4
4 2

output:

1 2 3 4

result:

ok Correct

Test #2:

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

input:

4
4 5
1 2
2 3
3 4
3 1
1 4
5 3
1 2
2 3
3 4
9 10
3 5
1 8
5 8
4 9
6 7
7 9
1 2
1 4
2 4
4 6
8 10
1 4
3 8
2 5
3 4
1 5
5 8
2 8
5 7
4 5
3 7

output:

-1
1 2 3
2 3 1 7 8 4 10 9 5 6
-1

result:

ok Correct

Test #3:

score: 0
Accepted
time: 674ms
memory: 4440kb

input:

50
3214 2907
970 1929
2860 3033
1322 2296
931 1192
861 2505
831 2469
231 2549
1 2306
1765 1842
999 3171
177 2007
1798 1894
827 3180
673 1738
1163 1573
2213 2781
2766 3200
1663 2197
1797 2281
315 2637
442 2689
558 2874
1520 2591
651 1923
1133 2920
1747 2412
1104 1528
313 2487
632 3124
660 2182
1581 2...

output:

8 593 1336 438 1050 1822 606 788 1547 2110 2297 271 659 242 431 1510 1799 2154 220 374 2104 2902 2868 1485 2210 2232 771 1459 653 1029 2504 31 2554 2604 1696 2330 2639 995 1066 2843 2897 106 760 1479 73 62 171 1363 158 1122 1383 829 63 576 599 927 1642 499 540 590 821 381 300 873 1827 369 794 1581 2...

result:

ok Correct

Test #4:

score: 0
Accepted
time: 15ms
memory: 4044kb

input:

48
732 104
388 425
176 558
7 695
504 507
163 705
204 456
139 432
104 716
535 582
254 682
70 278
77 385
600 680
373 564
197 653
335 569
81 579
339 604
407 580
253 383
480 549
145 308
52 373
426 525
268 359
408 595
47 397
479 569
268 403
477 663
434 660
330 343
56 692
376 450
200 553
299 713
114 584
1...

output:

3 101 48 57 72 66 53 27 63 23 14 33 98 71 79 11 12 17 69 97 99 52 43 8 38 58 37 42 16 28 94 103 56 55 75 73 82 74 34 47 54 7 81 44 22 64 5 49 2 92 59 80 50 102 15 35 93 88 77 6 83 62 60 20 10 40 100 104 51 1 87 25 29 95 70 61 41 36 78 32 91 65 18 84 39 76 85 19 26 24 89 96 31 67 46 90 30 21 4 9 68 4...

result:

ok Correct

Test #5:

score: 0
Accepted
time: 561ms
memory: 4988kb

input:

24
3635 2454
724 2161
994 3233
30 278
2047 3627
693 1048
112 2609
9 1552
889 946
987 2538
923 1911
53 1198
2429 3200
1338 3544
504 2644
1116 3446
815 877
245 3601
2177 3180
212 1638
1140 3241
159 2455
2447 2460
957 1585
980 2338
1254 3014
382 3596
510 595
1408 2300
2053 2276
2177 3415
1051 3353
136 ...

output:

1920 29 794 908 1493 1606 1512 2155 724 1148 1806 64 1501 159 985 655 2168 1948 1004 682 569 1096 1231 79 1782 742 966 1970 1840 59 651 1479 1215 1390 1488 2418 2025 353 594 14 864 1063 2391 1272 1528 2373 1069 973 2196 201 1923 514 28 1985 1823 2288 1309 74 1042 1093 442 1279 1687 1206 663 2448 993...

result:

ok Correct

Test #6:

score: 0
Accepted
time: 262ms
memory: 4232kb

input:

56
2367 1768
132 2148
1280 2214
473 2270
78 2126
374 2080
777 1617
74 152
46 125
36 1136
1340 2010
1536 1801
291 619
610 1567
1688 2303
1005 2308
1101 1988
1695 2257
1056 1405
1134 1579
1819 2281
1281 1952
2065 2102
1984 2353
215 1994
984 2258
1916 2059
1128 2198
966 1048
965 1424
866 932
227 543
33...

output:

1274 1049 1609 1054 606 1202 721 290 525 70 161 396 395 88 1579 1577 40 988 641 451 809 1222 1219 424 755 1604 1453 1052 420 1350 1186 1548 583 1580 577 112 1451 982 1373 1677 610 282 532 587 1525 125 464 1176 1334 1643 1134 1601 723 765 1216 663 366 171 4 108 658 1169 604 987 1057 1218 295 722 534 ...

result:

ok Correct

Test #7:

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

input:

56
1804 2031
215 520
41 228
505 1449
1202 1467
175 474
583 1684
127 1013
11 1132
251 1009
1333 1516
22 633
168 1160
866 1584
1501 1510
425 1494
563 1764
1341 1646
76 114
541 943
163 166
103 184
455 1225
708 1649
836 1551
551 1381
570 1509
125 221
371 1117
436 1012
392 732
76 379
1040 1359
119 1405
1...

output:

-1
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
6 14 16 2 17 19 18 3 10 13 11 9 5 8 1 4 7 20 12 15
1 2 14 9 13 15 12 4 20 3 17 7 ...

result:

ok Correct

Test #8:

score: 0
Accepted
time: 3ms
memory: 3932kb

input:

38
17 122
7 11
1 8
2 13
5 6
6 10
9 17
6 13
10 12
2 9
12 14
14 15
3 8
8 12
3 16
3 17
6 16
5 12
4 11
11 16
5 13
5 17
1 4
1 10
8 15
2 16
3 10
6 7
5 7
2 17
10 17
7 12
3 6
9 11
6 17
4 6
9 16
1 16
12 15
7 17
9 10
1 5
10 15
7 10
3 13
1 14
8 14
4 5
4 17
1 17
8 17
7 8
1 2
10 13
11 15
15 16
2 12
2 11
3 7
8 9
...

output:

-1
-1
-1
-1
-1
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
6 14 16 2 17 19 18 3 10 13 11 9 5 8 1 4 7 20 12 15
1 2 14 9 13 15 12 ...

result:

ok Correct

Test #9:

score: 0
Accepted
time: 3ms
memory: 3880kb

input:

61
12 66
11 12
5 8
9 12
4 9
2 9
6 12
2 11
1 2
3 6
3 12
6 10
5 6
2 12
10 12
8 12
7 8
7 9
2 8
3 11
3 9
3 10
8 11
2 6
5 12
5 9
4 7
4 5
4 6
5 11
1 3
5 7
1 7
7 10
5 10
6 7
4 12
3 5
4 8
2 3
1 8
6 11
4 11
3 7
1 5
3 4
9 11
1 10
4 10
6 9
7 11
1 4
8 9
10 11
1 11
7 12
1 9
9 10
1 12
6 8
8 10
2 10
2 5
3 8
2 7
1 ...

output:

-1
-1
-1
-1
-1
-1
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
6 14 16 2 17 19 18 3 10 13 11 9 5 8 1 4 7 20 12 15
1 2 14 9 13 15 ...

result:

ok Correct

Test #10:

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

input:

18
51 1255
24 43
42 51
4 36
29 31
41 42
43 48
10 26
30 40
4 51
25 42
24 42
2 6
3 24
6 21
34 46
5 10
2 37
12 41
19 25
1 2
18 22
1 20
45 49
3 22
14 25
16 25
26 31
25 48
36 45
24 29
34 39
26 29
6 37
18 38
2 51
10 22
15 26
30 33
1 15
10 37
17 33
11 22
28 32
32 39
13 17
21 28
8 23
20 46
8 38
5 44
5 30
4 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
6 14 16 2 17 19 18 3 10 13 11 9 5 8 1 4 7 20 12 15
1 2 14 9 ...

result:

ok Correct

Test #11:

score: 0
Accepted
time: 3ms
memory: 3816kb

input:

61
22 223
1 22
10 22
2 7
19 20
13 17
17 21
18 19
15 16
9 17
5 19
5 8
12 18
4 17
10 20
2 10
4 15
7 11
16 19
5 20
3 14
3 17
7 12
3 21
4 11
17 22
10 17
8 21
9 20
6 11
2 20
5 7
3 18
9 22
13 22
6 14
14 19
5 12
4 22
2 3
14 17
12 16
7 20
5 10
4 7
4 13
1 19
10 13
1 20
13 19
4 6
11 19
3 11
9 14
8 15
3 16
2 8...

output:

-1
-1
-1
-1
-1
-1
-1
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
6 14 16 2 17 19 18 3 10 13 11 9 5 8 1 4 7 20 12 15
1 2 14 9 13 ...

result:

ok Correct

Test #12:

score: 0
Accepted
time: 1224ms
memory: 4736kb

input:

1
4000 4000
1248 3248
260 3260
344 1017
843 3949
451 1483
275 1413
231 3477
264 940
567 1383
1072 3173
830 3445
437 2322
929 1624
1221 2034
3297 3458
1412 1642
837 2505
1918 3259
554 2070
3630 3807
1217 3188
3149 3199
949 1179
2697 3656
802 2039
2496 3757
1073 2857
765 2310
178 3862
1385 2597
1870 2...

output:

829 1188 2624 3690 129 110 3028 2348 1172 2128 120 356 1624 1804 3656 907 732 139 648 2778 3581 2088 3662 870 1619 1747 2761 1604 3163 1019 2012 2526 2659 2893 2738 1697 410 640 2049 3760 3826 1953 2479 1060 538 836 984 1028 387 1279 2070 2729 2069 3278 112 1127 3745 831 994 1407 1679 2114 874 1228 ...

result:

ok Correct

Test #13:

score: 0
Accepted
time: 1192ms
memory: 5208kb

input:

1
4000 4000
224 2401
586 2589
379 1471
1805 2518
2145 2874
2310 3019
2487 3160
1729 3934
762 971
2734 3272
2633 2673
846 2606
1047 1755
2907 3577
2329 3026
2121 2725
375 3941
966 3109
30 1389
2721 3284
93 1944
2018 3260
384 2761
2318 3964
2917 3784
123 2934
409 3449
3701 3869
1343 2534
1171 2588
584...

output:

2138 728 1376 1961 2404 775 2519 2605 3848 510 1469 222 1627 2919 1783 3139 922 407 1071 2151 2315 2397 504 91 2482 303 315 1047 96 413 3006 3118 3863 1145 1877 272 525 399 936 2766 2925 3473 1669 1999 2778 3295 761 3811 962 2354 2473 3053 1947 3807 825 1979 1049 2011 2341 3708 69 194 1667 2706 2881...

result:

ok Correct

Test #14:

score: 0
Accepted
time: 1206ms
memory: 5168kb

input:

1
4000 4000
2254 2471
2217 2613
3360 3617
152 3820
3226 3879
1688 3423
172 595
2149 2514
2373 3866
456 1567
8 1047
438 2143
1738 2761
219 3396
2476 2574
3209 3535
3572 3903
707 3740
810 1693
1866 3504
199 2163
1085 1137
104 2414
37 1979
3376 3387
1359 1860
816 1070
864 3772
1163 3054
2481 3600
1535 ...

output:

2184 2105 217 2609 1688 1850 2423 411 1015 549 468 628 2188 2509 1097 15 2778 3520 3686 1174 492 3383 1996 2692 78 815 174 346 410 1044 1268 2889 1838 2273 2698 3151 3677 3623 3810 3547 3597 1590 211 112 572 396 902 962 2821 3 1123 2545 3692 297 1195 3345 519 1243 3995 3188 666 1553 3624 2942 3278 2...

result:

ok Correct

Test #15:

score: 0
Accepted
time: 1213ms
memory: 4916kb

input:

1
4000 4000
1391 3587
137 3069
434 3678
630 1365
1721 2147
1885 3917
372 2688
215 1678
2581 2989
628 934
547 838
1835 2960
2265 3755
1393 3277
1906 3593
3053 3131
174 601
2770 3541
855 3399
320 3525
948 3966
3095 3976
560 3642
2417 3751
481 2338
2888 3493
19 3482
270 3754
922 1699
3272 3313
2066 376...

output:

1641 987 3381 1465 2435 843 1427 3424 530 2859 2712 3672 3724 529 580 1068 1369 1568 2309 3871 3909 3085 633 1379 387 484 1390 3 687 927 1529 2787 954 1872 2738 3623 384 755 998 1841 3004 1096 1983 26 1043 692 2259 437 1783 1547 3161 2922 3037 3577 2636 3350 3033 2078 2815 3548 3908 252 261 278 1373...

result:

ok Correct

Test #16:

score: 0
Accepted
time: 1237ms
memory: 4788kb

input:

1
4000 4000
857 1354
1781 2427
2049 3631
1583 2512
100 839
1824 2596
566 2096
2754 3971
8 3882
1291 1410
2768 2909
2481 3957
153 2599
340 3385
1911 2004
2161 2476
340 3663
44 1333
1034 3119
46 2602
2088 2164
2543 3112
127 2347
1056 1149
1837 2173
1715 3124
2750 3739
1584 1904
2951 3483
665 1963
127 ...

output:

538 248 144 761 211 1658 1801 2154 3695 271 652 2469 2917 1005 745 1214 2180 594 1016 1443 2856 3430 295 3389 1018 1111 141 176 92 229 1788 1877 2757 408 471 1371 2039 2170 110 11 587 724 1118 1392 569 628 2406 2157 2499 1209 1478 1829 921 3426 3431 3518 2822 2911 2152 2342 2451 2820 2391 2952 2695 ...

result:

ok Correct

Test #17:

score: 0
Accepted
time: 1236ms
memory: 4960kb

input:

1
4000 4000
1849 3380
891 1650
1804 1937
3314 3847
124 3415
1489 3545
1000 3552
2600 3390
2047 2407
442 1613
2632 3692
2049 3312
495 589
145 1811
2345 2769
3666 3892
783 3201
584 1116
1406 1953
368 2322
1709 3910
1481 2979
1025 2467
1404 2572
1893 3528
413 518
619 917
111 3212
716 2004
280 793
1219 ...

output:

1298 363 2032 462 1442 3262 3656 216 527 30 1658 1058 2250 3738 1354 2761 377 2072 821 2254 592 835 1994 29 341 771 3918 1822 3185 207 647 3783 392 1501 2937 7 703 2282 3487 380 2004 2943 433 1818 3099 444 636 805 1774 2301 2530 2330 848 2284 3574 3799 2055 973 1733 2876 3957 1083 1823 3022 1245 170...

result:

ok Correct

Test #18:

score: 0
Accepted
time: 1209ms
memory: 4812kb

input:

1
4000 4000
383 1621
1774 3258
129 2251
1694 2640
386 3612
477 1611
434 3737
1413 1920
2054 3773
94 1165
167 2412
1813 2474
2011 2115
2371 3915
229 1651
2553 3489
908 2479
687 2505
2227 3042
219 402
1404 1784
864 1828
798 3431
643 1755
1445 2283
1325 1659
832 1426
3320 3722
48 176
1859 3930
2996 340...

output:

103 960 1255 3230 3479 1760 3214 2814 3297 3431 1763 3346 1554 2146 2655 211 320 2600 940 2160 2923 330 1914 1609 1216 3197 1032 1721 2251 2553 2601 3039 3190 94 267 797 1584 3504 735 1435 971 1040 1632 1923 1087 1179 3148 2825 2965 2998 3097 2206 977 2860 3829 1457 1725 3809 3720 999 2078 3132 3760...

result:

ok Correct

Test #19:

score: 0
Accepted
time: 1220ms
memory: 5192kb

input:

1
4000 4000
2069 2090
745 803
3546 3918
1002 2097
94 442
158 403
1655 2002
941 1223
1669 3905
2108 2455
2812 3571
430 3214
327 2575
1240 3428
422 1160
914 2219
3 1449
108 3284
2398 3908
555 1207
1924 3504
1472 3187
2360 3247
2174 2420
2753 2758
1536 2813
699 950
2321 3501
1040 3308
159 1706
7 2088
2...

output:

36 941 1374 3054 3622 3693 737 3911 821 1639 828 1799 680 17 1517 1895 3944 1415 2018 2097 2413 2899 2595 2445 3932 3150 1576 667 956 1658 2598 2785 2054 3153 3455 609 3015 1382 3590 187 1557 465 770 1631 2769 2292 637 682 1352 3575 1378 1003 2256 2377 743 1145 2162 2691 3360 823 1490 3901 3369 3026...

result:

ok Correct

Test #20:

score: 0
Accepted
time: 1210ms
memory: 5016kb

input:

1
4000 4000
1388 3080
144 796
229 2513
1648 3222
2292 3099
1881 2771
1200 1281
2240 2865
1634 2573
2066 2604
464 1615
2711 3961
2851 3143
3102 3567
1621 3707
3536 3568
201 3996
1176 2466
2201 3318
805 3076
1454 1550
2455 3385
2522 3598
1353 2032
1312 1747
1142 3879
404 2183
2276 3828
1592 2571
1993 ...

output:

689 348 2179 3958 768 2989 324 292 1489 881 1572 3022 1018 3574 295 1059 1482 3925 3804 161 1034 1509 1648 1339 136 1289 2265 506 651 13 459 825 2094 854 1397 1464 2659 3115 1722 2975 1069 2166 3570 2096 68 756 2829 326 135 864 3405 204 243 3643 3759 2953 3769 2544 452 1395 77 1974 2390 3097 3714 26...

result:

ok Correct

Test #21:

score: 0
Accepted
time: 1218ms
memory: 4800kb

input:

1
4000 4000
599 1640
57 3563
1764 2956
415 1083
988 2327
2258 3583
1721 2866
117 322
216 1491
2904 3861
1781 3007
1552 2059
1436 2167
2359 2733
1289 1543
929 2422
2529 3473
1494 1536
2483 2735
945 2118
3404 3813
1163 2724
2208 3585
342 2425
609 1888
3412 3825
956 2277
3005 3287
1468 3761
757 3952
12...

output:

60 3282 1821 1721 3675 68 2213 1775 14 182 372 634 1714 964 1333 2170 3615 1541 351 1076 2207 558 3470 1784 2453 793 1477 2315 2970 3008 3493 469 1129 1773 2968 394 1853 74 1071 1418 2197 2610 273 2086 3281 3292 3204 156 578 2613 886 1787 3307 3469 619 42 940 1205 1320 919 163 235 553 751 1414 1538 ...

result:

ok Correct

Test #22:

score: 0
Accepted
time: 1201ms
memory: 4780kb

input:

1
4000 4000
124 2437
1479 1738
2506 3836
336 1763
489 1840
2193 2457
1139 2167
1975 3010
858 2835
763 2778
1474 1959
615 2586
603 2843
105 3410
868 1922
663 2136
286 1999
1705 3905
443 2261
1545 1879
1696 2785
928 1128
1698 3691
517 820
475 2735
1660 1688
1374 1947
16 500
1217 2310
626 3355
825 3368...

output:

2214 191 7 1423 2429 2820 1113 2651 127 333 480 715 780 1029 1805 3329 1078 3565 3599 671 1081 2145 3917 1453 3561 1933 2911 3788 97 222 1687 1940 3627 3631 533 743 2632 3783 139 402 1198 1380 658 631 1504 1643 2073 2879 685 1120 2703 3450 1368 2707 1834 3563 2444 2991 3248 3560 3993 1796 2534 2882 ...

result:

ok Correct

Test #23:

score: 0
Accepted
time: 1210ms
memory: 4984kb

input:

1
4000 4000
2640 2931
781 1781
1356 2326
899 3001
112 3416
2176 3058
1963 2402
3734 3821
929 1637
1184 3733
2286 2423
251 3134
481 3204
652 857
3056 3355
34 1347
1237 2171
116 1048
1313 2773
1638 3625
2602 3486
1984 2942
817 3986
2889 3974
2581 3245
1203 1729
68 673
1879 2976
3598 3695
1428 3062
166...

output:

487 620 1608 3309 676 3139 115 1614 781 2890 3133 3969 490 512 343 2063 938 696 753 2664 2744 2861 336 1072 1651 1906 148 457 723 1079 1137 451 1622 1658 2201 2379 3019 3317 3626 3901 2619 3191 89 411 813 1592 1503 2347 3923 3942 3963 2396 2931 3983 138 158 1895 3339 1955 3526 2525 443 1192 2073 208...

result:

ok Correct

Test #24:

score: 0
Accepted
time: 1205ms
memory: 4880kb

input:

1
4000 4000
2584 3827
1642 3825
1231 1269
1968 3847
2014 3281
1042 2109
3063 3559
2264 2280
1187 2797
1103 3689
2380 3524
1334 3514
2892 2981
60 70
264 3761
97 3633
214 2878
371 2369
878 3044
1916 3642
693 3366
1368 3262
71 1787
919 2662
1897 2838
46 395
1 2677
1051 2591
102 1130
876 3903
706 2657
5...

output:

27 149 499 606 753 2548 1790 877 1548 2142 1146 2546 3439 1263 100 432 876 2348 3394 369 795 3901 1799 1571 647 1330 15 1124 591 1004 2066 419 671 1227 2203 3151 3537 3612 635 782 2915 2138 2154 3254 3513 3937 1421 2748 50 429 942 1152 1233 3607 1436 1498 359 542 2414 2678 2443 2274 2875 3865 3459 2...

result:

ok Correct

Test #25:

score: 0
Accepted
time: 1208ms
memory: 4784kb

input:

1
4000 4000
547 2591
286 3922
2196 3068
2578 2917
835 1266
3148 3157
187 2045
872 951
1181 1665
1404 3787
1455 3381
1709 1931
3951 3955
416 992
1498 1591
2757 3441
3740 3906
126 3458
3670 3960
1767 3262
354 3956
316 1176
1407 3778
2319 2762
1125 2344
3083 3477
413 1410
739 2013
1993 3133
1683 2194
2...

output:

2040 1210 1213 2815 2311 940 48 1454 3712 43 45 754 600 2108 2573 3991 3275 3669 2053 638 1276 2658 675 810 912 3493 95 1035 1508 467 1142 348 612 645 2049 3353 3683 962 2168 3727 2174 3245 3741 1324 3341 273 2158 2638 3878 51 243 357 1513 2200 979 1066 3547 1468 327 1612 1039 3662 284 380 444 782 1...

result:

ok Correct

Test #26:

score: 0
Accepted
time: 1221ms
memory: 4732kb

input:

1
4000 4000
1030 1263
132 3186
430 2576
636 3420
1262 3141
599 2920
796 2546
1384 3451
275 1134
788 3228
1933 2752
1862 3696
1946 2286
137 1550
723 1944
1790 3458
2117 3103
905 1318
489 1003
17 1115
704 3506
1028 2129
3108 3154
1765 3098
536 2877
1278 1672
1919 3753
3189 3542
1172 2258
2379 3010
248...

output:

1140 3427 930 820 2294 2855 2875 2794 2153 701 2430 2509 2394 3362 2574 2483 2998 14 698 2816 3324 3547 3664 3522 3007 1440 3902 139 145 408 1411 2874 2898 3352 2063 3084 1766 1107 2051 2143 3343 3428 3186 3030 2835 1068 1141 1460 605 224 213 456 2978 3132 3584 418 1934 1117 1271 1093 247 1139 56 96...

result:

ok Correct

Test #27:

score: 0
Accepted
time: 1243ms
memory: 4852kb

input:

1
4000 4000
183 1656
21 2247
1518 1680
2834 3783
156 1065
557 1358
759 1845
1390 2208
191 1559
546 3980
1892 3508
1239 1251
2735 3088
305 644
2642 3483
708 1799
748 1634
601 1141
736 1413
640 2977
698 1568
2266 3837
2705 3388
512 2528
18 3087
484 1959
2547 3604
3178 3542
396 2064
324 3070
1616 3693
...

output:

1399 3938 3443 99 2514 667 1539 142 1542 1959 1849 2183 343 1540 2314 3474 59 245 970 296 1011 2480 2619 568 901 1829 3590 3838 671 827 2017 580 1105 2212 3079 2497 836 1293 1478 2828 2837 3015 3510 3687 3731 757 2349 323 1340 1910 2766 3833 1500 2100 2414 2135 2586 2775 990 2222 2120 3253 3498 3906...

result:

ok Correct

Test #28:

score: 0
Accepted
time: 1204ms
memory: 5024kb

input:

1
4000 4000
567 2891
2734 2894
2315 3205
293 3742
1306 3744
186 2629
2544 3454
566 3863
2489 2670
886 1213
1771 3242
4 2136
1384 3689
1974 3078
336 1482
471 2301
2553 3063
1640 2046
3020 3456
2164 3972
2294 2646
554 3475
1960 2990
89 1020
563 2120
973 1827
149 2943
2158 2858
982 3543
995 3049
498 34...

output:

3023 373 785 377 1321 493 420 2289 935 1649 1007 601 1462 528 896 1865 2277 3138 1961 2839 3034 3743 945 3736 2902 2421 1624 1407 1698 19 2383 2798 2320 523 944 1782 2429 1016 1793 2412 3477 2619 2830 2886 1324 160 1800 1289 2330 3791 3926 340 2205 466 344 514 914 2075 2212 2875 3618 3141 2453 2655 ...

result:

ok Correct

Test #29:

score: 0
Accepted
time: 1231ms
memory: 4988kb

input:

1
4000 4000
73 1104
1963 3399
1916 3595
1759 1941
1144 2204
861 3316
1415 2794
260 3545
411 428
1137 1416
2280 3214
127 2192
2793 3102
2048 2157
933 3017
1500 2353
513 3976
892 3236
2269 2434
532 2551
2927 3537
229 2810
2457 3568
1891 2380
2514 3483
1915 2167
2501 3286
346 1808
3181 3903
383 2516
15...

output:

469 1233 358 1285 3844 486 841 2618 23 113 183 699 1328 2289 781 52 1958 2808 2199 2237 2316 32 392 1075 1099 3562 206 1989 2683 2225 413 935 1096 2045 3020 2300 1121 2305 2358 3588 3796 1262 1034 409 1593 1649 2399 920 494 179 2465 245 2615 3793 660 805 1629 744 2290 2767 2954 3441 2711 2584 2588 1...

result:

ok Correct

Test #30:

score: 0
Accepted
time: 1231ms
memory: 4852kb

input:

1
4000 4000
82 3284
1814 2006
1618 2435
57 2861
232 2959
169 2668
1718 2748
506 3604
2148 2231
3110 3993
3589 3875
1690 3387
256 3376
1067 1531
43 3211
2724 3985
675 3128
323 701
50 1754
251 2459
3086 3775
3328 3506
1158 2762
1870 3879
467 1410
1044 2314
2381 2485
957 1432
693 1700
75 1656
34 2290
1...

output:

3920 539 1200 1532 3110 2011 1533 59 1250 780 886 3492 49 1503 1692 128 3712 3783 1284 2974 744 1195 3360 568 601 2559 3276 224 727 2925 1298 3975 159 681 296 538 632 323 2390 649 3318 2917 3641 540 869 1734 2690 3181 3196 1349 2008 2080 3255 304 332 1861 1989 2279 79 856 1666 1839 25 1931 2038 34 1...

result:

ok Correct

Test #31:

score: 0
Accepted
time: 1233ms
memory: 4896kb

input:

1
4000 4000
1837 3254
678 3631
2009 3325
2084 2160
954 1704
266 3555
1857 1923
1584 3192
1855 3080
978 3030
1513 2113
1085 1279
2186 2256
359 2276
245 416
2087 2172
1561 3688
2495 3233
894 1710
2337 2866
1150 2428
481 1172
2668 3079
2440 2745
3362 3935
2470 3359
2890 3602
2681 2940
2033 3792
2995 39...

output:

1365 1591 139 1272 1425 207 927 190 2269 2373 1418 96 2233 3903 310 1296 614 2474 2730 118 2466 3647 1436 3203 1014 1224 285 791 955 2416 2560 342 447 18 400 2408 1319 2799 3021 1451 1790 2640 116 3987 3697 3778 3529 904 1097 1550 3175 3206 3815 1230 2087 2842 2315 1292 2610 3862 466 690 1376 994 30...

result:

ok Correct

Test #32:

score: 0
Accepted
time: 1205ms
memory: 4864kb

input:

1
4000 4000
2666 2788
1806 3099
799 2195
252 2483
1011 1837
1177 1351
754 2378
386 2651
2444 3234
1836 3950
1718 3367
2171 3630
1177 2162
2017 2708
2226 2308
2022 2183
1004 1086
944 2510
669 3126
545 731
253 3292
2218 2491
2695 2948
1009 3866
247 3119
1497 3806
1061 3704
648 2105
1349 2085
2566 3245...

output:

2706 693 1893 3104 1039 333 1533 2977 1846 2434 427 573 1547 483 1074 28 861 3539 1820 1259 859 3205 3289 1454 308 2123 891 3732 3880 327 1222 2466 2671 3195 3372 1805 1666 1985 265 2128 578 1320 1770 1061 955 1176 1076 839 2105 497 1974 1986 2534 2656 2884 2783 3352 3601 3113 2627 3778 2281 1171 23...

result:

ok Correct

Test #33:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

70
2 1
1 2
3 1
1 2
3 1
1 3
3 2
1 2
1 3
3 1
2 3
3 2
1 2
2 3
3 2
1 3
2 3
3 3
1 2
1 3
2 3
4 1
1 2
4 1
1 3
4 2
1 2
1 3
4 1
1 4
4 2
1 2
1 4
4 2
1 3
1 4
4 3
1 2
1 3
1 4
4 1
2 3
4 2
1 2
2 3
4 2
1 3
2 3
4 3
1 2
1 3
2 3
4 2
1 4
2 3
4 3
1 2
1 4
2 3
4 3
1 3
1 4
2 3
4 4
1 2
1 3
1 4
2 3
4 1
2 4
4 2
1 2
2 4
4 2
1...

output:

1
1
1
1 2
1
1 2
1 2
1 2 3
1
1
1 2
1
1 2
1 2
1 2 3
1
1 2
1 2
1 2 3
1 2
1 3 2
1 3 2
1 2 3 4
1
1 2
1 2
1 3 2
1 2
1 2 3
1 2 3
1 2 3 4
1 2
1 2 3
1 2 3
1 4 2 3
1 3 2
1 3 2 4
1 3 2 4
-1
1
1 2
1 2
1 2 3
1 2
1 2 3
1 2 3
1 2 3 4
1 2
1 2 3
1 2 3
1 2 4 3
1 3 2
1 3 2 4
1 3 2 4
-1
1 2
1 2 3
1 3 2
1 3 2 4
1 2 3
1 ...

result:

ok Correct

Test #34:

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

input:

255
5 1
1 2
5 1
1 3
5 2
1 2
1 3
5 1
1 4
5 2
1 2
1 4
5 2
1 3
1 4
5 3
1 2
1 3
1 4
5 1
1 5
5 2
1 2
1 5
5 2
1 3
1 5
5 3
1 2
1 3
1 5
5 2
1 4
1 5
5 3
1 2
1 4
1 5
5 3
1 3
1 4
1 5
5 4
1 2
1 3
1 4
1 5
5 1
2 3
5 2
1 2
2 3
5 2
1 3
2 3
5 3
1 2
1 3
2 3
5 2
1 4
2 3
5 3
1 2
1 4
2 3
5 3
1 3
1 4
2 3
5 4
1 2
1 3
1 4
...

output:

1
1
1 2
1
1 2
1 2
1 2 3
1
1 2
1 2
1 2 3
1 2
1 2 3
1 2 3
1 2 3 4
1
1 2
1 2
1 2 3
1 2
1 3 2
1 3 2
1 2 3 4
1 2
1 3 2
1 3 2
1 2 3 4
1 2 3
1 4 2 3
1 4 2 3
1 2 3 4 5
1
1 2
1 2
1 3 2
1 2
1 2 3
1 2 3
1 2 3 4
1 2
1 3 2
1 2 3
1 4 2 3
1 3 2
1 2 3 4
1 2 4 3
1 2 3 4 5
1 2
1 2 3
1 2 3
1 4 2 3
1 3 2
1 3 2 4
1 3 2 ...

result:

ok Correct

Test #35:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

256
5 1
3 5
5 2
1 2
3 5
5 2
1 3
3 5
5 3
1 2
1 3
3 5
5 2
1 4
3 5
5 3
1 2
1 4
3 5
5 3
1 3
1 4
3 5
5 4
1 2
1 3
1 4
3 5
5 2
1 5
3 5
5 3
1 2
1 5
3 5
5 3
1 3
1 5
3 5
5 4
1 2
1 3
1 5
3 5
5 3
1 4
1 5
3 5
5 4
1 2
1 4
1 5
3 5
5 4
1 3
1 4
1 5
3 5
5 5
1 2
1 3
1 4
1 5
3 5
5 2
2 3
3 5
5 3
1 2
2 3
3 5
5 3
1 3
2 3
...

output:

1
1 2
1 2
1 2 3
1 2
1 2 3
1 3 2
1 2 4 3
1 2
1 2 3
1 2 3
1 2 3 4
1 2 3
1 2 3 4
1 2 3 4
1 2 3 4 5
1 2
1 2 3
1 2 3
1 2 4 3
1 2 3
1 3 4 2
1 3 4 2
1 2 5 3 4
1 3 2
1 3 2 4
1 3 2 4
-1
1 2 4 3
1 4 2 3 5
1 4 2 3 5
-1
1 2
1 2 3
1 3 2
1 3 2 4
1 2 3
1 2 3 4
1 4 2 3
1 2 3 4 5
1 3 2
1 3 2 4
1 2 4 3
1 4 2 3 5
1 3 ...

result:

ok Correct

Test #36:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

256
5 1
4 5
5 2
1 2
4 5
5 2
1 3
4 5
5 3
1 2
1 3
4 5
5 2
1 4
4 5
5 3
1 2
1 4
4 5
5 3
1 3
1 4
4 5
5 4
1 2
1 3
1 4
4 5
5 2
1 5
4 5
5 3
1 2
1 5
4 5
5 3
1 3
1 5
4 5
5 4
1 2
1 3
1 5
4 5
5 3
1 4
1 5
4 5
5 4
1 2
1 4
1 5
4 5
5 4
1 3
1 4
1 5
4 5
5 5
1 2
1 3
1 4
1 5
4 5
5 2
2 3
4 5
5 3
1 2
2 3
4 5
5 3
1 3
2 3
...

output:

1
1 2
1 2
1 2 3
1 2
1 2 3
1 2 3
1 2 3 4
1 2
1 2 3
1 2 3
1 2 3 4
1 2 3
1 2 3 4
1 2 3 4
1 2 3 4 5
1 2
1 2 3
1 2 3
1 2 3 4
1 3 2
1 3 2 4
1 3 2 4
1 2 3 4 5
1 3 2
1 3 2 4
1 3 2 4
1 2 3 4 5
1 2 4 3
1 4 2 3 5
1 4 2 3 5
1 2 3 4 5 6
1 2
1 2 3
1 2 3
1 3 4 2
1 2 3
1 2 4 3
1 2 3 4
1 2 3 5 4
1 3 2
1 3 2 4
1 2 4 ...

result:

ok Correct

Test #37:

score: 0
Accepted
time: 1ms
memory: 3872kb

input:

256
5 2
3 5
4 5
5 3
1 2
3 5
4 5
5 3
1 3
3 5
4 5
5 4
1 2
1 3
3 5
4 5
5 3
1 4
3 5
4 5
5 4
1 2
1 4
3 5
4 5
5 4
1 3
1 4
3 5
4 5
5 5
1 2
1 3
1 4
3 5
4 5
5 3
1 5
3 5
4 5
5 4
1 2
1 5
3 5
4 5
5 4
1 3
1 5
3 5
4 5
5 5
1 2
1 3
1 5
3 5
4 5
5 4
1 4
1 5
3 5
4 5
5 5
1 2
1 4
1 5
3 5
4 5
5 5
1 3
1 4
1 5
3 5
4 5
5 6
...

output:

1 2
1 2 3
1 2 3
1 2 3 4
1 3 2
1 2 4 3
1 3 2 4
1 2 4 3 5
1 2 3
1 2 3 4
1 2 4 3
1 2 3 5 4
1 2 3 4
1 2 3 4 5
-1
-1
1 2 3
1 2 3 4
1 2 3 4
1 2 4 3 5
1 4 3 2
1 3 4 2 5
1 3 4 2 5
1 2 5 3 4 6
1 3 2 4
1 3 2 5 4
1 3 2 5 4
-1
1 2 4 5 3
1 2 3 5 6 4
-1
-1
1 3 2
1 2 4 3
1 3 4 2
1 3 2 4 5
1 2 4 3
1 2 5 3 4
1 4 2 3...

result:

ok Correct

Test #38:

score: 0
Accepted
time: 533ms
memory: 5032kb

input:

1
4000 3994
2609 1656
3268 840
769 1738
3439 1042
3805 288
1790 1841
2661 3157
3560 2665
3486 2381
725 3579
2621 2158
2246 3697
2923 1728
565 2922
2150 2856
1972 2196
1010 790
3817 2083
1909 3542
2536 2939
141 2051
3293 800
843 706
3267 3007
473 3411
3389 2798
693 599
2647 771
2350 210
2783 2619
359...

output:

952 3235 3234 951 3231 3232 3236 3233 3230 3229 950 3227 3228 949 3226 3225 948 3223 3224 947 3222 3221 946 3219 3220 945 3218 3217 944 3215 3216 943 3214 3213 942 3211 3212 941 3210 3209 940 3207 3208 939 3206 3205 938 3203 3204 937 3202 3201 936 3199 3200 935 3198 3197 934 3195 3196 933 3194 3193 ...

result:

ok Correct

Test #39:

score: 0
Accepted
time: 539ms
memory: 4960kb

input:

1
4000 3996
3022 1706
217 798
3846 114
1413 3018
1914 2614
2737 120
1511 998
3898 3588
726 3783
475 1138
2071 46
2287 369
2419 2400
1970 1133
2429 3343
1760 531
2021 388
3907 1515
1114 3687
1840 2881
1136 1398
3946 1314
1171 3958
1575 1610
2533 2909
2745 953
818 1846
3062 1891
3123 3143
2892 3318
37...

output:

-1

result:

ok Correct

Test #40:

score: 0
Accepted
time: 529ms
memory: 5008kb

input:

1
4000 3994
910 3139
3000 219
801 2172
1962 161
2284 653
810 1548
300 852
335 2572
1922 2795
2970 482
423 1596
490 3372
348 2771
2483 558
3454 3931
577 2060
2517 821
3534 1670
2030 848
2581 170
1031 3044
1178 3114
1146 3183
2412 1931
1629 2266
3436 1299
3533 1183
3918 2053
3196 3604
3830 1721
1230 4...

output:

923 3177 3176 922 3173 3174 3178 3175 3172 3171 921 3169 3170 920 3168 3167 919 3165 3166 918 3164 3163 917 3161 3162 916 3160 3159 915 3157 3158 914 3156 3155 913 3153 3154 912 3152 3151 911 3149 3150 910 3148 3147 909 3145 3146 908 3144 3143 907 3141 3142 906 3140 3139 905 3137 3138 904 3136 3135 ...

result:

ok Correct

Test #41:

score: 0
Accepted
time: 609ms
memory: 4788kb

input:

1
4000 3996
1307 3803
1514 2254
79 1282
937 1493
1163 1895
2180 1780
2043 3379
2284 1084
2261 1455
3101 3256
2588 3494
910 3568
2539 1793
1013 1443
1647 1030
117 1694
2285 444
2892 2348
3090 2114
3605 338
3574 2922
1926 3831
786 852
1680 1078
3886 1004
3437 3838
2448 1122
350 1681
1726 3717
3610 232...

output:

-1

result:

ok Correct

Test #42:

score: 0
Accepted
time: 523ms
memory: 5004kb

input:

1
4000 3994
1092 3679
2596 1292
1283 2710
627 3944
3067 3817
3512 2530
2271 220
2546 2881
1005 2267
3768 489
2682 2737
847 3134
3276 3719
2750 2087
1789 1395
1839 2956
1103 924
2766 316
1506 818
3634 3050
621 350
1957 1361
2399 528
1964 3573
2810 374
919 900
874 1429
224 952
1931 860
590 700
1409 10...

output:

453 2237 2236 452 2233 2234 2238 2235 2232 2231 451 2229 2230 450 2228 2227 449 2225 2226 448 2224 2223 447 2221 2222 446 2220 2219 445 2217 2218 444 2216 2215 443 2213 2214 442 2212 2211 441 2209 2210 440 2208 2207 439 2205 2206 438 2204 2203 437 2201 2202 436 2200 2199 435 2197 2198 434 2196 2195 ...

result:

ok Correct

Test #43:

score: 0
Accepted
time: 662ms
memory: 4908kb

input:

1
4000 3996
133 3956
3856 2401
1161 3631
2436 992
653 2913
940 3748
2096 1276
1293 3978
934 723
3975 15
2357 3454
1832 597
240 3319
3719 843
1808 3229
1019 3178
1742 2306
3161 2356
1867 1565
1897 2317
1465 1695
2602 452
1011 1858
3599 2738
3821 3143
2047 2082
444 3438
960 2619
220 2729
427 1228
1928...

output:

-1

result:

ok Correct

Test #44:

score: 0
Accepted
time: 192ms
memory: 4136kb

input:

1
1805 1711
394 1668
457 489
128 212
799 1388
82 1084
583 1469
1041 1188
710 1402
789 1711
341 453
430 1219
170 557
538 1356
240 661
994 1150
71 626
1301 1647
544 1316
770 1755
307 1296
574 1482
363 1260
128 986
596 1245
452 1020
1249 1619
194 1410
425 887
23 854
1377 1557
793 1359
361 1771
177 1464...

output:

455 544 1233 1279 1617 62 4 1548 290 385 698 110 220 320 1222 198 814 1340 1505 427 748 914 1352 1406 1561 219 411 462 1399 135 587 1029 1310 419 1581 75 527 1488 204 829 518 966 1518 1185 1697 1266 962 71 157 158 229 1018 1191 1523 1405 1565 1709 993 703 655 704 896 1010 201 386 484 646 1441 203 11...

result:

ok Correct

Test #45:

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

input:

42
17 23
2 8
10 11
1 10
9 17
5 12
1 4
7 13
13 15
8 12
3 6
3 5
1 17
8 11
2 14
8 17
6 13
13 14
7 12
6 15
2 16
10 17
5 15
4 16
19 22
10 16
7 12
9 11
15 17
9 18
11 17
5 17
1 4
7 11
11 14
2 11
14 18
6 15
18 19
6 8
2 19
5 8
13 18
1 18
16 18
1 14
5 6
15 17
8 13
3 13
4 9
1 5
5 15
3 8
7 12
4 7
7 11
5 14
11 1...

output:

3 2 6 12 4 15 21 1 9 13 20 5 22 8 7 16 10 17 19 11 18 14 23
8 21 10 12 5 14 18 20 19 6 9 11 3 16 7 22 13 15 17 4 2 1
4 5 10 13 7 8 9 11 3 12 14 6 1 17 16 2 15
8 6 9 4 15 1 3 5 13 7 12 2 10 11 17 14 16
17 2 7 11 12 16 3 13 6 10 5 19 18 1 4 8 15 9 14 20
17 8 10 18 2 19 21 7 20 13 5 6 3 22 9 1 12 14 16...

result:

ok Correct

Test #46:

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

input:

55
17 18
3 17
5 6
1 7
6 10
10 11
8 17
1 6
1 14
6 15
7 14
9 11
5 12
5 7
3 10
12 16
2 3
2 9
3 9
16 20
12 15
8 11
7 16
8 12
11 13
3 14
13 16
4 16
3 9
5 8
2 15
10 12
3 12
4 13
2 10
9 14
1 5
8 14
1 15
7 11
19 25
12 15
12 13
8 11
4 6
11 18
7 10
6 17
3 19
7 16
5 16
10 16
5 14
12 17
3 8
4 15
6 9
5 8
1 16
16...

output:

3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
6 14 16 2 17 19 18 3 10 13 11 9 5 8 1 4 7 20 12 15
1 2 14 9 13 15 12 4 20 3 17 7 11 ...

result:

ok Correct

Test #47:

score: 0
Accepted
time: 6ms
memory: 3608kb

input:

15
54 58
31 37
40 44
29 48
19 54
35 36
13 25
5 42
21 41
25 46
5 7
16 50
22 31
14 30
3 7
12 13
2 26
12 25
38 49
19 40
2 27
3 11
11 38
45 46
11 32
39 51
46 48
14 43
40 54
16 45
8 9
18 19
9 41
13 52
21 46
21 50
35 38
30 44
20 35
36 41
19 43
14 50
29 49
27 44
36 45
27 43
23 29
5 48
15 31
33 45
37 38
4 2...

output:

16 20 45 27 40 4 58 19 2 31 28 37 43 41 52 13 11 56 6 9 15 33 17 23 44 49 26 34 29 8 35 32 5 39 3 42 47 46 38 18 22 50 36 24 57 14 21 7 10 54 55 30 53 1 12 48 51 25
5 17 22 39 9 11 2 13 19 15 30 28 46 18 16 36 31 1 40 8 14 42 47 21 35 20 26 6 33 29 3 4 10 37 23 27 24 32 34 12 41 45 7 25 44 38 43
6 2...

result:

ok Correct

Test #48:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

62
15 17
7 10
4 7
7 9
10 11
3 10
10 15
4 15
3 12
9 13
1 14
6 14
2 14
2 9
1 8
1 13
1 6
11 15
12 15
10 12
8 12
4 10
3 5
4 9
3 7
3 11
6 7
6 11
1 8
4 8
5 11
9 10
2 12
2 6
19 22
14 16
1 17
6 19
6 14
11 15
3 8
13 16
5 14
16 18
9 19
5 9
1 7
1 3
7 17
10 19
2 18
2 5
8 18
11 13
4 8
4 7
16 19
15 19
8 10
9 12
4...

output:

10 11 12 14 15 16 9 3 13 1 4 5 6 7 17 2 8
10 11 3 1 5 13 14 2 15 9 12 4 6 7 8
2 12 21 13 14 6 18 20 9 1 8 7 22 3 10 15 4 17 11 16 19 5
13 16 5 7 6 17 15 12 8 1 9 18 3 4 10 11 19 2 14
2 20 13 17 22 10 12 18 8 3 19 15 14 5 4 6 16 21 7 11 9 1
12 10 2 4 1 5 11 6 7 16 9 8 14 17 15 3 13
3 7 8 11 2 18 9 6 ...

result:

ok Correct

Test #49:

score: 0
Accepted
time: 1188ms
memory: 5200kb

input:

3
3960 3967
937 3123
2575 3091
263 2767
2233 3478
552 3510
812 3093
721 3160
1830 3890
1854 3310
407 1115
866 1033
1204 3558
1866 2279
1964 2250
2036 2929
1129 3111
1725 1994
378 958
2761 3502
2488 2494
1802 2046
99 2510
2998 3872
366 3221
1726 1936
1659 3352
3568 3579
497 969
2272 3691
2274 3167
55...

output:

310 1313 1581 2866 2999 3317 2711 3123 724 1986 3387 284 1648 1107 2566 2227 3694 511 2540 2528 3897 552 257 1744 3224 2003 468 373 1211 2634 2670 2186 934 1110 169 2228 453 579 877 2636 3503 3585 3782 2080 115 576 1141 2644 2850 3949 2918 3624 2507 2393 1360 3239 2471 3615 2964 3153 33 2239 2631 12...

result:

ok Correct

Test #50:

score: 0
Accepted
time: 1189ms
memory: 4776kb

input:

4
3955 3943
363 1845
92 111
2718 2963
314 3924
1365 1859
1420 2183
1237 1803
935 2088
2201 3595
383 2157
1936 2467
1318 3215
1375 3931
2621 3099
1532 3716
3188 3696
143 2696
2022 2484
1740 2309
1772 3772
1231 2205
1049 1563
67 2068
2588 3667
1020 2460
961 2113
171 526
965 2881
1019 1212
851 3174
417...

output:

109 255 476 3494 411 1831 430 471 1142 2886 2339 2373 768 461 932 1376 2059 3359 1629 2699 2761 2978 1770 1862 1567 873 2194 3121 184 165 629 870 1013 1362 1148 3722 1937 2123 2739 2797 3442 586 815 2181 2477 64 346 1115 1573 1107 1578 3236 3626 2895 675 1095 634 902 1365 166 1589 2027 118 1042 1876...

result:

ok Correct

Test #51:

score: 0
Accepted
time: 1209ms
memory: 4896kb

input:

2
3989 3960
932 3335
2784 3545
1581 3968
2252 2687
1066 3050
54 1103
1987 3568
921 3151
405 1546
1510 3800
987 2778
1725 3388
605 680
2325 2456
594 3276
539 542
1192 3674
1127 1426
1064 3074
1816 2273
97 3867
742 892
366 1639
809 1385
108 776
358 1409
572 3242
1586 3090
1543 1845
1665 2114
162 2413
...

output:

1006 1045 1813 2339 1753 3229 1870 766 1264 547 3297 2848 1505 22 399 601 3128 550 563 2670 2824 2370 892 146 2856 2963 668 2402 3407 3570 1698 1059 1472 434 667 2219 1021 1375 324 679 773 1805 2397 1967 15 2192 1632 2611 728 495 1056 870 2287 3035 3815 371 2295 2121 3043 3366 2173 1339 380 2794 360...

result:

ok Correct

Test #52:

score: 0
Accepted
time: 1198ms
memory: 5136kb

input:

1
3937 3994
2877 3051
771 3317
1788 2832
1167 3673
1409 3682
1417 1965
1466 3052
99 3464
491 592
2914 3230
2090 3824
976 2867
273 1897
1515 2245
951 3578
670 2098
2900 3629
82 1098
1014 1107
2687 3483
605 2523
1653 2240
3545 3558
1727 1970
2887 3037
2756 3177
567 2697
3345 3869
407 2133
493 1519
110...

output:

2200 1477 2601 1951 909 53 723 1439 932 1356 1373 521 74 475 1702 62 2090 2525 3036 3271 414 1874 2547 2787 3272 3768 2254 3227 1700 1988 2190 3245 792 3175 229 2412 923 1404 3311 1832 2409 2702 3097 3597 3256 3431 3913 2038 415 1695 1820 2717 1052 60 1858 471 1244 1243 2133 3263 3454 2867 2198 2771...

result:

ok Correct

Test #53:

score: 0
Accepted
time: 1206ms
memory: 5140kb

input:

3
3965 3964
299 1234
3303 3667
3065 3181
570 1699
1835 3939
999 1041
1332 2928
2791 3878
2230 3582
2595 3637
1680 3886
1772 1972
3556 3781
2525 3809
2276 2380
1753 3384
413 2245
556 2652
754 3856
1550 1814
392 1136
692 2314
690 1570
1589 2676
2217 2249
3674 3734
742 1421
377 724
2334 3673
1920 2787
...

output:

1813 971 1106 1427 3816 3953 2594 3720 322 357 1814 2299 616 717 1395 1763 2600 64 2350 3041 3300 2878 3718 2080 2977 3136 97 1129 1753 724 837 473 866 2287 2382 443 448 1350 2760 1240 1570 2059 52 1956 648 1466 2932 3341 2224 3311 2166 3441 2781 2711 3142 3253 3877 2689 1852 3149 3837 3688 1140 226...

result:

ok Correct

Test #54:

score: 0
Accepted
time: 6ms
memory: 3720kb

input:

53
78 34
7 16
1 21
37 39
37 76
19 52
60 63
2 42
16 34
51 63
9 14
5 37
68 78
12 22
58 62
17 53
39 67
15 16
15 30
37 72
10 18
18 52
35 39
22 64
39 47
21 53
57 70
31 40
29 76
6 51
29 57
31 54
44 73
59 74
10 25
52 17
4 34
21 48
32 51
46 48
22 40
4 18
12 25
1 47
3 48
1 44
33 51
7 49
14 16
14 52
35 36
9 3...

output:

2 25 15 7 11 3 16 22 24 4 28 30 26 19 29 9 6 1 8 17 18 10 20 21 5 34 13 23 27 31 32 14 33 12
8 10 9 2 4 1 6 17 3 11 12 16 7 13 14 5 15
28 30 34 16 39 12 46 33 18 6 37 36 8 7 38 40 14 25 32 19 4 31 21 29 22 41 10 11 3 5 26 43 27 1 24 9 13 15 42 23 44 17 45 2 20 35
22 31 21 9 17 23 6 15 11 24 3 1 30 2...

result:

ok Correct

Test #55:

score: 0
Accepted
time: 8ms
memory: 3652kb

input:

56
61 87
12 21
3 28
26 52
21 55
28 51
8 30
10 28
7 45
8 42
3 51
9 35
12 44
30 59
8 22
6 38
35 61
20 46
5 61
26 31
1 37
24 38
38 43
13 21
8 9
48 54
8 18
39 47
16 19
2 20
9 41
18 47
4 26
10 55
19 36
1 50
15 41
33 54
26 61
6 61
22 33
36 50
7 53
22 31
9 30
16 18
60 61
12 22
40 61
5 37
18 32
28 31
40 41
...

output:

-1
1
7 12 16 9 11 4 10 18 19 6 15 20 3 17 21 13 5 2 1 8 14
1 3 4 2 6 5
-1
-1
16 24 19 27 21 4 12 15 13 26 35 17 18 44 45 41 31 30 43 32 40 11 34 37 29 47 3 22 38 2 1 7 5 23 10 39 42 28 6 20 9 25 8 36 46 33 14
5 3 6 2 4 1
10 20 15 21 8 18 4 6 1 9 12 13 22 17 14 16 5 19 2 7 23 3 11
10 7 2 8 1 9 14 5 3...

result:

ok Correct

Test #56:

score: 0
Accepted
time: 9ms
memory: 3648kb

input:

57
80 33
2 36
11 30
15 20
20 21
27 75
21 27
70 78
72 80
49 71
19 20
5 24
23 38
37 79
52 76
27 33
21 52
52 80
5 57
5 32
17 59
42 71
35 68
36 57
50 71
1 74
12 77
53 79
3 62
28 75
67 70
68 71
4 69
35 49
86 161
20 21
74 84
52 57
39 50
22 33
21 27
53 74
11 42
62 72
1 65
35 42
46 53
43 84
59 63
5 34
34 39...

output:

25 1 23 18 11 19 28 32 2 26 3 4 6 5 29 15 16 14 17 8 10 20 12 22 33 9 21 24 31 13 27 30 7
-1
14 16 1 8 4 19 18 10 5 11 15 9 3 2 6 13 17 7 12
7 19 5 14 10 2 12 15 3 8 11 16 17 9 18 4 13 1 6
21 1 10 52 28 38 67 7 40 64 32 50 58 54 51 55 5 33 12 2 59 63 74 79 13 69 46 62 75 24 45 6 77 66 57 15 29 78 26...

result:

ok Correct

Test #57:

score: 0
Accepted
time: 8ms
memory: 3644kb

input:

54
63 18
2 46
15 63
21 53
16 32
14 37
21 27
5 10
53 54
17 51
18 54
51 57
15 60
26 60
31 41
16 26
11 21
20 27
8 47
57 108
36 37
30 35
13 23
29 30
3 27
7 28
44 51
14 38
4 38
28 40
23 52
22 27
20 47
8 23
15 30
53 54
7 42
28 45
9 45
18 34
1 41
2 12
26 31
17 18
1 30
26 43
10 31
2 5
30 39
31 38
42 52
21 4...

output:

1 7 18 16 3 8 10 6 17 5 2 12 13 15 4 9 11 14
-1
-1
-1
3 9 2 8 7 17 12 4 10 5 15 1 6 14 11 16 13
2 17 23 19 26 47 20 38 16 8 18 51 41 48 32 9 37 39 46 33 35 31 24 4 14 5 10 1 44 29 7 25 28 11 3 30 13 22 21 52 34 50 49 27 36 43 6 15 40 42 45 12
7 2 1 6 9 3 4 8 5
21 40 52 1 44 30 43 51 10 15 31 25 5 42...

result:

ok Correct

Test #58:

score: 0
Accepted
time: 9ms
memory: 3720kb

input:

55
65 56
11 23
42 53
1 37
25 51
23 51
31 42
44 45
29 30
22 23
7 18
23 64
4 58
3 58
35 52
24 36
5 13
10 55
27 33
21 40
1 45
19 57
12 49
8 54
26 61
46 52
11 25
9 44
46 57
19 62
23 35
17 55
33 35
18 47
24 43
4 20
45 48
2 51
7 28
28 60
32 65
10 24
25 57
55 65
41 64
33 62
19 55
4 61
32 41
4 8
16 32
13 36...

output:

3 20 7 27 36 53 34 15 51 56 14 30 1 5 4 42 37 9 11 26 21 29 46 28 32 18 45 25 17 31 43 54 41 40 50 44 48 16 6 2 52 55 23 49 12 13 35 47 24 10 33 38 39 22 19 8
-1
-1
-1
62 29 14 22 16 21 41 1 23 35 8 10 51 19 46 47 13 38 27 37 40 3 6 2 57 26 55 24 60 59 56 43 28 30 31 48 20 42 36 15 33 34 49 32 54 39...

result:

ok Correct

Test #59:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

1
72 86
38 44
43 64
8 65
20 49
9 12
5 15
36 69
6 55
16 59
2 48
2 11
33 60
41 67
5 26
25 31
10 44
39 59
6 13
16 71
7 10
20 25
25 54
13 14
15 53
3 17
30 63
38 57
2 44
61 63
54 57
43 62
23 59
6 14
38 47
22 27
61 72
15 65
2 66
54 55
53 64
4 55
35 69
1 66
14 21
33 58
30 50
4 67
22 64
33 62
9 24
5 51
36 5...

output:

74 6 14 51 61 24 40 2 48 35 85 62 31 37 72 56 49 63 3 66 57 77 76 42 69 78 12 67 86 52 45 7 22 21 30 27 1 28 34 83 18 8 79 23 44 33 20 58 16 59 84 41 39 15 4 32 60 9 17 25 71 68 13 47 54 73 26 46 36 29 10 11 38 81 64 65 53 19 5 50 80 55 75 70 43 82

result:

ok Correct

Test #60:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

5
17 23
2 8
10 11
1 10
9 17
5 12
1 4
7 13
13 15
8 12
3 6
3 5
1 17
8 11
2 14
8 17
6 13
13 14
7 12
6 15
2 16
10 17
5 15
4 16
19 22
10 16
7 12
9 11
15 17
9 18
11 17
5 17
1 4
7 11
11 14
2 11
14 18
6 15
18 19
6 8
2 19
5 8
13 18
1 18
16 18
1 14
5 6
15 17
8 13
3 13
4 9
1 5
5 15
3 8
7 12
4 7
7 11
5 14
11 12...

output:

3 2 6 12 4 15 21 1 9 13 20 5 22 8 7 16 10 17 19 11 18 14 23
8 21 10 12 5 14 18 20 19 6 9 11 3 16 7 22 13 15 17 4 2 1
4 5 10 13 7 8 9 11 3 12 14 6 1 17 16 2 15
8 6 9 4 15 1 3 5 13 7 12 2 10 11 17 14 16
17 2 7 11 12 16 3 13 6 10 5 19 18 1 4 8 15 9 14 20

result:

ok Correct

Test #61:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

5
17 18
3 17
5 6
1 7
6 10
10 11
8 17
1 6
1 14
6 15
7 14
9 11
5 12
5 7
3 10
12 16
2 3
2 9
3 9
16 20
12 15
8 11
7 16
8 12
11 13
3 14
13 16
4 16
3 9
5 8
2 15
10 12
3 12
4 13
2 10
9 14
1 5
8 14
1 15
7 11
19 25
12 15
12 13
8 11
4 6
11 18
7 10
6 17
3 19
7 16
5 16
10 16
5 14
12 17
3 8
4 15
6 9
5 8
1 16
16 ...

output:

3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15
19 1 12 13 6 18 9 16 2 10 4 11 15 17 5 7 3 8 14 20
21 3 14 17 10 12 5 23 9 11 19 18 22 8 6 20 2 13 25 4 16 15 7 1 24
2 1 13 20 15 19 4 14 5 12 18 3 7 6 8 16 10 11 21 9 17
3 16 10 5 6 11 4 2 9 1 7 12 14 8 15 13

result:

ok Correct

Test #62:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

1
54 58
31 37
40 44
29 48
19 54
35 36
13 25
5 42
21 41
25 46
5 7
16 50
22 31
14 30
3 7
12 13
2 26
12 25
38 49
19 40
2 27
3 11
11 38
45 46
11 32
39 51
46 48
14 43
40 54
16 45
8 9
18 19
9 41
13 52
21 46
21 50
35 38
30 44
20 35
36 41
19 43
14 50
29 49
27 44
36 45
27 43
23 29
5 48
15 31
33 45
37 38
4 28...

output:

16 20 45 27 40 4 58 19 2 31 28 37 43 41 52 13 11 56 6 9 15 33 17 23 44 49 26 34 29 8 35 32 5 39 3 42 47 46 38 18 22 50 36 24 57 14 21 7 10 54 55 30 53 1 12 48 51 25

result:

ok Correct

Test #63:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

1
100 94
49 67
71 72
15 90
29 1
97 81
100 25
5 80
55 63
99 56
9 98
94 32
44 22
73 91
77 58
2 50
46 14
66 12
20 13
70 38
31 93
65 78
16 95
74 11
48 30
86 19
7 41
4 39
60 21
35 52
61 62
10 23
82 92
49 71
67 72
71 15
72 90
15 29
90 1
29 97
1 81
97 100
81 25
100 5
25 80
5 55
80 63
55 99
63 56
99 9
56 98...

output:

4 39 38 3 35 36 40 37 34 33 2 1 41 42 5 44 43 6 45 46 7 48 47 8 49 50 9 52 51 10 53 54 11 56 55 12 57 58 13 60 59 14 61 62 15 64 63 16 65 66 17 68 67 18 69 70 19 72 71 20 73 74 21 76 75 22 77 78 23 80 79 24 81 82 25 84 83 26 85 86 27 88 87 28 89 90 29 92 91 30 93 94 31 32

result:

ok Correct

Test #64:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

1
100 96
50 96
7 47
83 28
81 9
20 54
70 36
73 17
78 52
85 65
40 71
49 37
19 6
91 63
38 72
41 33
25 24
88 1
74 56
84 8
26 97
82 23
13 69
48 2
16 32
93 64
100 5
62 44
87 31
4 61
27 75
94 67
60 76
50 7
96 47
7 83
47 28
83 81
28 9
81 20
9 54
20 70
54 36
70 73
36 17
73 78
17 52
78 85
52 65
85 40
65 71
40...

output:

-1

result:

ok Correct

Test #65:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

1
100 94
26 70
86 8
82 42
94 3
79 98
55 45
25 99
2 71
12 47
22 48
13 76
75 17
46 80
57 96
65 9
41 74
28 38
6 63
88 83
43 72
51 53
14 90
40 4
69 36
5 85
19 77
87 60
29 93
58 31
50 66
78 44
30 49
26 86
70 8
86 82
8 42
82 94
42 3
94 79
3 98
79 55
98 45
55 25
45 99
25 2
99 71
2 12
71 47
12 22
47 48
22 1...

output:

8 48 45 7 44 43 47 46 41 42 6 40 39 5 37 38 4 36 35 3 33 34 2 1 50 49 9 51 52 10 54 53 11 55 56 12 58 57 13 59 60 14 62 61 15 63 64 16 66 65 17 67 68 18 70 69 19 71 72 20 74 73 21 75 76 22 78 77 23 79 80 24 82 81 25 83 84 26 86 85 27 87 88 28 90 89 29 91 92 30 94 93 31 32

result:

ok Correct

Test #66:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

1
100 96
48 24
77 1
97 80
36 90
68 11
98 76
30 51
40 7
85 70
28 4
54 42
96 3
39 18
83 93
66 56
64 75
2 63
31 55
23 61
33 99
26 50
52 58
15 47
8 32
65 62
34 92
82 100
22 67
27 5
78 95
53 81
87 14
48 77
24 1
77 97
1 80
97 36
80 90
36 68
90 11
68 98
11 76
98 30
76 51
30 40
51 7
40 85
7 70
85 28
70 4
28...

output:

-1

result:

ok Correct

Test #67:

score: 0
Accepted
time: 1ms
memory: 3904kb

input:

1
100 94
26 7
53 92
36 61
33 29
67 34
39 42
47 68
10 1
27 73
20 57
13 2
66 90
46 63
96 76
40 74
95 64
54 44
28 8
85 31
59 4
60 5
11 79
45 25
51 3
86 52
48 43
78 91
55 62
37 21
94 22
14 16
30 97
26 53
7 92
53 36
92 61
36 33
61 29
33 67
29 34
67 39
34 42
39 47
42 68
47 10
68 1
10 27
1 73
27 20
73 57
2...

output:

8 47 46 7 43 44 48 45 42 41 6 39 40 5 38 37 4 35 36 3 34 33 2 1 49 50 9 52 51 10 53 54 11 56 55 12 57 58 13 60 59 14 61 62 15 64 63 16 65 66 17 68 67 18 69 70 19 72 71 20 73 74 21 76 75 22 77 78 23 80 79 24 81 82 25 84 83 26 85 86 27 88 87 28 89 90 29 92 91 30 93 94 31 32

result:

ok Correct

Test #68:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

4
37 55
4 11
8 22
5 36
1 24
11 16
13 15
9 28
14 18
8 9
11 15
15 23
12 21
29 32
16 29
9 32
6 19
16 18
3 32
12 35
1 12
22 26
10 22
3 6
11 17
2 30
1 2
35 36
8 26
10 26
34 36
12 13
7 12
26 30
1 4
27 34
24 29
1 26
12 18
25 31
7 32
2 17
16 30
28 29
8 19
26 35
4 21
20 35
1 13
14 23
3 5
16 28
15 33
31 32
10...

output:

-1
35 3 19 22 1 39 13 6 29 14 34 23 24 21 40 41 37 12 36 9 5 15 8 17 16 43 33 7 18 20 28 42 11 27 26 31 32 38 30 10 2 4 25
1
1

result:

ok Correct

Test #69:

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

input:

7
37 8
7 36
2 26
35 37
19 33
13 29
6 9
3 6
4 19
23 18
7 13
7 22
8 16
6 9
12 15
8 23
6 22
13 14
9 18
15 17
9 21
7 9
1 10
8 18
1 22
11 17
4 16
8 19
25 31
12 17
7 9
15 24
8 13
5 21
5 20
3 6
5 17
5 10
11 25
7 20
17 20
3 17
3 22
7 19
4 12
6 7
11 24
16 21
19 24
11 18
15 17
9 12
4 20
12 19
5 14
4 6
10 15
1...

output:

2 7 6 8 4 1 5 3
13 15 2 1 7 4 9 11 12 8 14 3 17 6 18 16 10 5
-1
1
1
1
1 2 4 3

result:

ok Correct

Test #70:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

4
78 47
29 39
52 74
5 70
50 78
35 50
43 65
32 43
49 66
44 52
22 57
38 60
32 57
43 52
24 55
39 51
20 64
62 66
22 43
42 61
36 41
57 71
64 67
20 72
7 16
63 65
22 65
5 73
60 62
4 11
33 39
21 74
19 71
10 49
25 27
37 43
43 51
7 26
25 49
3 6
25 39
42 64
34 64
36 76
10 39
35 43
25 26
34 50
2 1
1 2
15 11
13 ...

output:

39 29 3 27 24 37 46 34 40 1 15 30 44 33 8 38 17 28 11 36 6 25 7 13 18 10 35 45 26 21 12 32 2 31 9 5 4 47 42 16 23 22 41 19 14 20 43
1
2 1 11 9 3 10 4 6 7 5 8
-1

result:

ok Correct

Test #71:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

3
45 32
6 17
2 16
8 30
9 37
24 25
12 33
6 32
25 35
5 36
6 40
3 9
7 30
5 22
16 33
5 15
28 38
14 18
29 30
11 45
8 40
14 27
5 34
9 44
18 34
19 27
9 20
15 36
13 20
12 29
19 32
16 28
4 41
53 58
18 44
17 36
29 38
31 32
9 19
2 22
1 36
5 37
10 13
32 53
8 42
22 47
15 42
9 25
21 30
5 13
26 35
13 20
8 21
26 47...

output:

2 14 6 29 18 3 20 10 1 7 30 25 21 17 24 22 9 13 15 27 12 31 16 11 4 23 26 28 32 19 5 8
-1
1

result:

ok Correct

Test #72:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

3
50 79
12 39
18 46
3 32
36 42
23 26
11 14
9 10
5 25
4 18
14 28
14 42
43 48
47 49
12 49
1 2
16 44
7 35
6 31
8 24
9 39
21 38
6 16
10 37
25 39
31 47
21 24
28 39
35 37
20 50
5 46
10 36
20 37
45 47
20 33
2 44
21 47
4 41
22 33
30 32
3 12
30 45
8 17
27 43
43 47
20 22
19 20
14 36
36 38
20 42
39 40
29 48
44...

output:

-1
6 5 2 3 4 1
9 1 6 3 13 14 8 12 4 5 11 7 10 15 2

result:

ok Correct

Test #73:

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

input:

4
27 39
10 23
12 13
15 22
12 21
6 15
13 19
15 26
19 21
12 22
9 21
2 13
5 18
10 21
2 25
1 5
12 23
21 26
14 27
7 9
1 12
2 11
5 19
3 12
17 27
2 26
10 15
9 18
1 24
11 13
18 19
17 19
4 13
16 25
16 20
16 22
4 22
1 10
11 16
2 16
24 29
3 11
6 20
15 16
3 9
14 19
12 23
3 13
5 16
14 22
16 17
5 19
6 22
6 7
5 24...

output:

-1
-1
16 2 9 10 6 12 4 7 14 11 15 13 8 1 3 5
6 2 5 12 14 10 13 8 1 11 9 4 15 3 7

result:

ok Correct

Test #74:

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

input:

4
28 1
4 28
30 3
10 13
2 20
3 6
25 22
4 5
13 21
5 16
3 4
3 11
9 10
1 20
10 14
9 23
8 11
18 20
4 18
6 11
9 11
11 17
7 15
4 6
16 21
2 11
10 13
17 25
16 18
17 18
3 17
5 6
1 7
6 10
10 11
8 17
1 6
1 14
6 15
7 14
9 11
5 12
5 7
3 10
12 16
2 3
2 9
3 9

output:

1
2 3 1
7 11 22 3 1 4 17 18 12 2 5 10 14 15 19 13 6 8 9 20 21 16
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15

result:

ok Correct

Test #75:

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

input:

5
26 14
10 26
11 14
6 10
15 26
4 12
4 16
2 15
1 15
12 19
7 26
2 25
23 24
5 13
3 10
20 41
13 19
6 11
19 20
11 16
5 19
6 15
3 19
7 10
7 14
5 15
5 7
6 9
3 4
13 18
6 16
4 10
8 17
3 6
8 18
1 16
6 18
9 19
7 11
5 12
14 20
1 13
4 11
2 18
12 18
5 14
16 18
16 20
3 9
2 20
9 18
2 9
4 6
3 20
5 10
2 6
8 9
20 10
7...

output:

8 4 1 3 14 10 7 11 5 9 6 13 2 12
-1
7 5 9 3 1 6 4 10 2 8
5 4 1 3 6 2
13 5 6 14 12 10 3 1 8 2 4 7 9 11

result:

ok Correct

Test #76:

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

input:

4
26 5
8 24
3 26
12 14
5 24
10 26
22 11
4 20
1 13
7 15
2 18
4 22
2 17
2 12
2 20
1 10
2 19
7 12
27 5
16 25
14 19
7 27
5 12
3 25
17 18
3 17
5 6
1 7
6 10
10 11
8 17
1 6
1 14
6 15
7 14
9 11
5 12
5 7
3 10
12 16
2 3
2 9
3 9

output:

2 5 4 1 3
2 9 4 6 7 11 3 8 1 5 10
5 1 4 3 2
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15

result:

ok Correct

Test #77:

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

input:

4
26 1
13 23
29 1
6 25
20 3
7 12
13 15
1 13
17 18
3 17
5 6
1 7
6 10
10 11
8 17
1 6
1 14
6 15
7 14
9 11
5 12
5 7
3 10
12 16
2 3
2 9
3 9

output:

1
1
3 2 1
3 13 7 8 10 12 4 9 2 14 1 16 17 11 18 5 6 15

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed