QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#651205#4830. Transfer of DutyN_z_AC ✓8ms11812kbC++236.8kb2024-10-18 17:30:232024-10-18 17:30:24

Judging History

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

  • [2024-10-18 17:30:24]
  • 评测
  • 测评结果:AC
  • 用时:8ms
  • 内存:11812kb
  • [2024-10-18 17:30:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct time_helper{
#ifdef LOCAL
clock_t time_last;time_helper(){time_last=clock();}void test(){auto time_now=clock();std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;time_last=time_now;}~time_helper(){test();}
#else
void test(){}
#endif
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
int print_precision=10;bool print_T_endl=1;char print_between=' ';
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader;struct Writer;template<size_t id>struct read_tuple{template<typename...T>static void read(Reader&stream,std::tuple<T...>&x){read_tuple<id-1>::read(stream,x);stream>>get<id-1>(x);}};template<>struct read_tuple<0>{template<typename...T>static void read([[maybe_unused]]Reader&stream,[[maybe_unused]]std::tuple<T...>&x){}};template<size_t id>struct print_tuple{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){print_tuple<id-1>::print(stream,x);putchar(print_between);stream<<get<id-1>(x);}};template<>struct print_tuple<1>{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){stream<<get<0>(x);}};template<>struct print_tuple<0>{template<typename...T>static void print([[maybe_unused]]Writer&stream,[[maybe_unused]]const std::tuple<T...>&x){}};
struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename...T>Reader&operator>>(std::tuple<T...>&x){read_tuple<sizeof...(T)>::read(*this,x);return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}template<typename T1,typename T2>Reader&operator>>(std::pair<T1,T2>&x){*this>>x.first>>x.second;return *this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';
struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(const T&x){for(auto q:x){*this<<q;if(!is_class<decltype(q)>::value)*this<<print_between;}if(!is_class<typename T::value_type>::value&&print_T_endl)*this<<'\n';return *this;}template<typename...T>Writer&operator<<(const std::tuple<T...>&x){print_tuple<sizeof...(T)>::print(*this,x);if(print_T_endl)*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-print_precision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<print_precision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<print_precision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(const T&c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}template<typename T1,typename T2>Writer&operator<<(const std::pair<T1,T2>&x){*this<<x.first<<print_between<<x.second;if(print_T_endl)*this<<'\n';return *this;}Writer&operator<<(const std::string&str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<class Fun>class y_combinator_result{Fun fun_;public:template<class T>explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}template<class ...Args>decltype(auto) operator()(Args &&...args){return fun_(std::ref(*this), std::forward<Args>(args)...);}};template<class Fun>decltype(auto) y_combinator(Fun &&fun){return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));}

void init();void solve(int tc);
main()
{
	init();int t=1;
	// cin>>t;
	for(int tc=1;tc<=t;tc++)solve(tc);
}
void init()
{
}
mt19937_64 mt(0);
unsigned long long hsh[1000001];
void solve([[maybe_unused]]int tc)
{
	string role;
	cin>>role;
	for(int x=1;x<=1000000;x++)
	hsh[x]=mt();
	if(role=="start")
	{
		unsigned long long a=0,b=0;
		int n;
		cin>>n;
		while(n--)
		{
			int v;
			cin>>v;
			a^=v,b^=hsh[v];
			if(b==0)cout<<0<<endl;
			else if(1<=a&&a<=1000000&&hsh[a]==b)cout<<a<<endl;
			else cout<<-1<<endl;
		}
		cout<<a<<' '<<b<<endl;
	}
	else
	{
		unsigned long long a=0,b=0;
		int n;
		cin>>a>>b>>n;
		while(n--)
		{
			int v;
			cin>>v;
			a^=v,b^=hsh[v];
			if(b==0)cout<<0<<endl;
			else if(1<=a&&a<=1000000&&hsh[a]==b)cout<<a<<endl;
			else cout<<-1<<endl;
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 11652kb

input:

start
5
10
14
10
12
10

output:

10
-1
14
-1
-1
8 1727818840392093671

input:

resume
8 1727818840392093671
6
14
277
12
10
277
12

output:

-1
-1
-1
277
0
12

result:

ok 

Test #2:

score: 100
Accepted
time: 4ms
memory: 11464kb

input:

start
1
1

output:

1
1 2947667278772165694

input:

resume
1 2947667278772165694
1
1

output:

0

result:

ok 

Test #3:

score: 100
Accepted
time: 4ms
memory: 11488kb

input:

start
1
1000000

output:

1000000
1000000 13375711136326272395

input:

resume
1000000 13375711136326272395
2
1
1000000

output:

-1
1

result:

ok 

Test #4:

score: 100
Accepted
time: 4ms
memory: 11396kb

input:

start
2
1
1

output:

1
0
0 0

input:

resume
0 0
2
1000000
1000000

output:

1000000
0

result:

ok 

Test #5:

score: 100
Accepted
time: 4ms
memory: 11688kb

input:

start
3
1
2
3

output:

1
-1
-1
0 16083550185891024140

input:

resume
0 16083550185891024140
2
4
5

output:

-1
-1

result:

ok 

Test #6:

score: 100
Accepted
time: 4ms
memory: 11652kb

input:

start
5
483440
800458
959493
679027
187008

output:

483440
-1
-1
-1
-1
881740 1318588442111835185

input:

resume
881740 1318588442111835185
8
312653
808184
244728
372836
64144
525068
795548
379152

output:

-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 

Test #7:

score: 100
Accepted
time: 4ms
memory: 11456kb

input:

start
68
901287
581649
963302
839936
728540
414441
916931
567596
695928
364562
839701
726560
34000
85414
129234
413159
976576
799600
479209
808330
182632
685443
41419
207533
762418
206283
144088
679114
945142
919478
220106
992468
483248
197576
129732
123083
987094
712824
650777
907335
206313
958433
...

output:

901287
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
112458 17775335221555276237

input:

resume
112458 17775335221555276237
68
632048
873503
23659
234350
352724
63249
395634
638205
597162
368489
973286
290734
735407
636099
145516
176166
262275
936624
302002
344028
227364
297307
645242
206861
471059
139081
861346
172592
637220
698174
593758
561280
324011
489640
497542
657953
82088
553578...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 

Test #8:

score: 100
Accepted
time: 4ms
memory: 11624kb

input:

start
520
569396
440938
116732
473751
47601
877390
277114
259139
437475
193896
992342
402838
838349
33699
536576
163847
117713
927965
598864
939506
517156
87428
943725
624835
515205
108250
468405
990560
512040
343417
101050
944099
177534
73824
476709
772630
489775
929453
216227
822538
552185
208923
...

output:

569396
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
53183 17994345890169020596
700
707366
267047
407693
725807
896458
649723
322966
13478
797908
8465
563163
798321
831358
235782
473564
19913
929601
720398
521831
221253
936397
987947
63596
47475
259147
560605
188477
743888
948782
654739
934236
341826
67525
197899
989556
144568
618026
850867
550...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #9:

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

input:

start
8443
729060
666260
185101
382196
371654
40175
191745
696848
627288
695514
463530
357409
465277
741772
43361
979762
952428
178423
841409
405526
498821
973165
335585
375002
113423
365239
404592
237309
573524
962229
36036
696295
373438
251803
891072
633659
62534
157262
573215
610136
499209
762268...

output:

729060
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
400754 16904981389801216543
9886
420210
520488
188197
748478
206087
275961
54195
608381
155537
321018
415228
668078
924461
161132
119676
879347
707167
899509
348680
459789
490439
773296
166145
740279
863122
581710
69615
444211
182480
543538
452479
284383
565588
539092
957001
22888
230633
5668...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #10:

score: 100
Accepted
time: 3ms
memory: 11800kb

input:

start
95751
308697
772166
788484
646333
666534
92445
786509
646923
836713
476019
699260
122853
518658
556909
839126
518374
192398
728985
64716
176986
975947
644795
748557
310350
187984
204486
401437
532833
615053
995384
580446
107265
183547
188255
578145
852736
311107
298993
513464
829086
302554
710...

output:

308697
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
3869 12271611193447463469
84366
27218
701633
132961
472984
701389
698190
669373
935077
378738
192191
77653
557125
650845
266909
475045
934661
119608
959584
788489
234755
596450
958580
223648
245932
228632
187317
851898
217174
209683
723661
866509
294070
291163
75492
341391
949271
525339
44999...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #11:

score: 100
Accepted
time: 5ms
memory: 11768kb

input:

start
99888
2
1
2
1
2
1
1
2
2
2
2
2
2
1
1
2
1
1
1
1
2
2
1
2
1
2
2
1
1
2
1
2
2
1
2
1
2
2
1
2
2
2
1
2
1
2
2
2
2
2
1
2
2
1
2
1
2
2
1
2
2
2
2
1
1
2
1
2
1
2
1
2
1
2
1
1
1
1
1
1
2
1
1
2
1
1
2
2
1
1
2
1
2
2
1
2
2
1
2
1
1
1
2
2
2
1
1
1
1
1
2
1
2
1
2
1
2
1
2
2
2
2
2
1
2
1
1
1
2
1
2
1
1
2
1
2
2
1
2
2
1
1
1
1
...

output:

2
-1
1
0
2
-1
2
0
2
0
2
0
2
-1
2
0
1
0
1
0
2
0
1
-1
2
0
2
-1
2
0
1
-1
1
0
2
-1
1
-1
2
0
2
0
1
-1
2
0
2
0
2
0
1
-1
1
0
2
-1
1
-1
2
0
2
0
2
-1
2
0
1
-1
2
0
1
-1
2
0
1
0
1
0
1
0
2
-1
2
0
1
0
2
0
1
0
2
-1
1
-1
2
0
2
-1
1
0
1
0
2
0
2
-1
2
-1
2
-1
1
0
2
-1
1
0
2
-1
1
-1
1
-1
1
0
2
-1
2
-1
1
0
2
-1
2
0
1
-...

input:

resume
0 0
99926
1
2
1
2
1
2
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
1
2
2
1
1
1
1
2
2
2
1
1
1
1
2
1
2
1
2
1
1
2
1
1
1
1
2
1
1
2
2
2
2
1
1
1
1
2
2
2
1
1
1
2
1
2
2
2
2
2
2
2
2
2
1
2
1
2
1
2
1
1
2
1
2
2
1
1
2
2
2
2
1
1
2
2
2
1
2
1
1
2
2
1
1
2
2
1
2
2
2
1
1
2
1
1
2
1
2
2
2
2
1
2
1
1
1
1
2
2
2
2
2
1
2
1
1
2...

output:

1
-1
2
0
1
-1
2
-1
1
-1
1
-1
1
-1
1
0
2
0
2
0
2
-1
1
-1
2
0
2
-1
2
-1
2
0
2
0
1
0
1
0
2
-1
1
0
2
-1
2
0
1
0
1
0
2
-1
2
0
2
0
2
-1
2
-1
2
0
2
0
1
0
1
-1
2
0
2
0
2
0
2
0
2
0
1
-1
2
0
1
-1
2
-1
1
0
2
0
1
0
2
0
2
0
1
0
2
0
2
-1
1
0
1
-1
1
0
1
-1
1
0
2
0
2
-1
2
0
1
0
2
-1
1
-1
1
-1
2
0
1
0
1
0
2
0
2
0
2
...

result:

ok 

Test #12:

score: 100
Accepted
time: 5ms
memory: 11572kb

input:

start
99918
2
2
1
3
1
3
1
3
3
3
1
2
2
1
3
3
3
1
3
3
2
2
1
1
2
3
3
3
3
3
1
1
2
3
3
1
3
2
3
3
1
1
2
1
2
1
2
1
3
2
1
2
2
3
2
3
1
3
1
3
3
3
1
2
1
3
2
2
1
2
3
1
3
1
2
3
3
1
3
3
2
1
3
3
3
1
1
1
2
3
2
2
3
3
1
2
3
2
2
2
3
3
3
2
2
1
3
2
3
1
3
2
2
3
2
2
1
3
3
2
3
3
2
2
3
3
2
2
3
2
2
2
1
3
3
1
3
3
2
2
3
1
3
1
...

output:

2
0
1
-1
3
0
1
-1
1
-1
3
-1
3
-1
1
-1
1
0
3
0
2
0
1
0
2
-1
2
-1
2
-1
-1
-1
3
0
3
-1
1
-1
-1
-1
2
-1
1
0
2
-1
1
0
3
-1
-1
-1
-1
-1
1
-1
3
0
1
-1
1
-1
3
-1
-1
-1
1
-1
2
0
3
-1
1
0
2
-1
2
-1
-1
-1
1
0
3
0
3
-1
3
-1
-1
-1
1
-1
-1
-1
2
0
3
-1
3
-1
2
-1
2
0
2
-1
-1
-1
1
0
3
-1
3
0
2
0
1
-1
1
-1
-1
-1
1
-1...

input:

resume
0 0
99905
2
3
3
1
2
2
2
2
1
1
1
3
2
1
1
2
1
3
2
2
2
2
1
1
3
1
2
1
1
1
1
1
2
3
2
3
1
3
1
2
3
3
2
3
1
2
3
2
2
3
2
3
2
1
3
1
1
2
3
2
1
3
1
1
3
1
2
3
2
2
2
2
3
1
2
1
2
2
2
1
3
1
2
2
2
2
1
2
1
3
3
3
1
3
2
2
2
3
1
3
2
3
3
2
1
2
3
1
1
2
1
1
2
1
1
2
1
2
3
2
3
3
1
2
1
1
1
3
2
1
1
3
3
2
3
1
3
1
2
3
1
2...

output:

2
-1
2
-1
1
-1
1
-1
2
-1
2
-1
3
-1
3
-1
-1
-1
1
-1
1
-1
2
-1
-1
-1
3
-1
3
-1
3
-1
-1
-1
1
-1
3
0
1
-1
-1
-1
1
-1
3
-1
2
0
2
-1
3
0
2
-1
-1
-1
-1
-1
1
-1
2
-1
-1
-1
2
-1
1
-1
-1
-1
-1
-1
1
0
2
-1
1
-1
1
0
3
-1
-1
-1
-1
-1
3
-1
-1
-1
-1
-1
2
-1
3
-1
3
0
1
-1
-1
-1
-1
-1
3
-1
2
-1
2
0
1
0
2
-1
2
0
1
-1...

result:

ok 

Test #13:

score: 100
Accepted
time: 5ms
memory: 11736kb

input:

start
99903
1
2
4
2
5
4
2
3
1
1
2
2
1
5
4
1
5
1
4
2
5
2
3
2
3
1
4
5
1
2
1
5
3
2
1
1
3
1
5
1
2
5
3
1
2
4
3
1
1
3
1
2
3
4
1
4
4
2
1
2
2
2
1
1
1
4
2
1
4
1
2
5
3
3
5
1
1
2
2
1
4
2
1
1
2
2
5
4
5
4
3
4
1
4
4
2
1
1
4
4
2
2
1
5
2
3
3
2
1
4
1
2
5
2
2
5
5
4
4
1
1
2
4
2
2
3
4
5
5
1
4
5
5
3
1
3
5
4
5
4
2
5
4
2
...

output:

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

input:

resume
3 17283517313888559305
99996
1
2
2
4
4
4
4
1
5
2
4
1
2
5
3
3
1
1
2
4
2
1
3
2
3
3
3
5
1
3
1
5
5
1
5
2
3
4
1
5
1
1
5
5
4
3
5
4
5
4
4
3
5
4
4
3
3
2
3
1
5
5
1
3
1
2
3
2
3
1
2
5
3
2
1
4
3
3
5
4
2
3
3
5
3
5
5
4
1
2
4
4
1
3
3
4
5
2
5
5
5
1
3
1
5
3
4
5
4
5
5
5
5
1
1
1
4
3
3
1
3
5
4
4
5
3
2
5
4
1
3
2
...

output:

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

result:

ok 

Test #14:

score: 100
Accepted
time: 5ms
memory: 11772kb

input:

start
99947
7
3
4
8
10
6
10
5
3
6
2
3
10
6
5
2
8
8
8
7
10
4
2
5
8
10
9
4
9
10
5
4
10
8
4
3
8
10
10
6
8
1
3
1
7
10
5
10
3
6
2
4
3
2
2
4
1
5
6
6
5
9
7
10
6
8
10
6
8
2
5
2
5
2
9
1
9
8
9
8
2
4
2
4
7
5
6
9
8
10
5
4
5
6
9
2
10
3
6
3
4
4
5
9
7
1
9
3
7
3
9
2
2
5
10
1
8
8
8
2
4
2
9
5
9
2
9
6
8
10
8
3
7
3
2
6...

output:

7
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

input:

resume
10 11740225476155230747
99934
9
7
1
7
5
4
5
3
2
7
4
1
9
7
10
9
9
7
9
8
8
1
6
9
3
1
5
4
1
4
1
3
3
5
3
4
7
7
1
3
6
6
7
3
10
4
9
6
5
2
3
8
3
7
9
1
4
4
4
3
4
2
8
7
5
7
4
3
4
3
2
4
5
3
2
6
7
5
7
4
4
2
4
3
5
1
1
6
1
1
10
5
7
4
9
7
9
2
3
3
7
7
1
5
5
9
3
2
5
3
2
2
9
10
5
1
3
3
4
5
7
8
3
8
4
8
4
9
10
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
8
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 

Test #15:

score: 100
Accepted
time: 5ms
memory: 11808kb

input:

start
99880
1
11
7
14
7
9
7
4
4
8
9
6
8
12
3
11
4
14
1
12
12
11
9
10
6
3
12
8
8
11
7
11
1
11
11
14
4
8
1
14
14
4
3
7
13
3
3
8
6
14
12
3
14
8
14
3
5
7
6
6
7
2
11
13
1
10
2
6
4
11
3
1
7
10
14
14
5
8
3
14
2
6
4
3
9
3
11
5
4
11
7
5
5
7
2
5
14
5
7
11
11
10
11
2
6
11
5
12
11
10
13
8
12
4
9
9
12
6
10
7
6
1...

output:

1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

input:

resume
10 16034557667177218660
99990
7
14
2
14
8
2
4
10
9
6
13
2
4
3
12
9
8
13
14
6
2
7
9
1
9
13
3
9
14
9
3
7
11
2
2
6
6
3
10
9
9
10
1
5
6
14
6
12
3
6
4
8
12
12
5
11
1
13
7
5
11
7
13
4
5
9
7
13
2
12
5
10
13
4
14
1
5
11
12
9
2
6
14
4
8
8
11
6
8
6
11
12
9
4
3
2
1
13
10
12
2
13
12
12
3
10
10
10
12
3
5
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #16:

score: 100
Accepted
time: 4ms
memory: 11576kb

input:

start
100000
394129
918049
227627
394129
227627
918049
730034
886281
958919
958919
730034
886281
108051
279991
756917
982336
982336
756917
620015
643225
671990
498572
965213
784067
302045
302045
448973
284292
498572
549214
671990
643225
646142
108051
598249
784067
315666
448973
695438
965213
620015
...

output:

394129
-1
-1
-1
918049
0
730034
-1
-1
-1
886281
0
108051
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
279991
0
149638
-1
149638
0
953158
-1
546431
-1
-1
-1
273407
-1
-1
-1
273407
0
555339
0
654326
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

input:

resume
41310 1494992118791878518
99998
929652
263139
663517
929652
696025
692392
138617
898592
906009
898592
906009
352125
138617
38059
383093
621629
662423
692392
4770
809970
907768
573182
742492
523142
414423
242561
621629
294780
358106
696025
376843
505429
185628
358106
573182
505429
587177
58717...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
523142
-1
82886
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
647066
-1
254973
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #17:

score: 100
Accepted
time: 7ms
memory: 11808kb

input:

start
99999
947665
127760
350354
669358
625042
583671
697219
193704
575165
512223
530130
575165
858585
999857
546323
127760
391941
697219
706174
947665
187941
698085
583671
544095
462885
530130
544095
706174
318321
669358
999857
421347
512223
858585
350354
49865
187941
755625
546323
625042
698085
19...

output:

947665
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
391941
0
660927
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

input:

resume
347142 16168107614454836559
99999
760123
766792
579853
240167
73960
897555
153744
712261
296311
466650
547887
945424
138542
382025
268581
601155
582110
562083
637382
394939
246308
574337
650987
91423
579853
219519
633159
921420
73960
982057
105695
201085
664753
593471
634123
650120
970834
760...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #18:

score: 100
Accepted
time: 7ms
memory: 11636kb

input:

start
99998
698147
885494
939196
838083
473356
306889
214611
177418
69534
569835
240345
400481
974284
780442
934650
284543
207419
603638
865861
553694
157688
99733
426984
23109
869388
214611
753442
762603
835849
511435
347206
300567
82280
377545
249724
300567
698147
503359
627471
481084
428245
76199...

output:

698147
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
373687 5389293770285487969
100000
695982
399589
248035
75122
38060
428168
16953
205044
961239
383210
612666
703796
392171
819603
230666
399589
905072
789767
148305
535597
12582
435468
905072
270287
329653
383210
241284
106231
716255
430228
581889
61343
954297
329653
12582
505088
505088
117759...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
714625
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 

Test #19:

score: 100
Accepted
time: 7ms
memory: 11572kb

input:

start
100000
30233
30233
955328
685299
955328
685299
44198
44198
522253
957054
966960
397858
859956
924705
282166
522253
324522
428464
678972
517929
707311
859956
661351
607572
678972
878203
705428
404580
661351
337730
878203
592906
592906
923695
970896
397858
404580
165775
970896
924705
428464
3377...

output:

30233
0
955328
-1
685299
0
44198
0
522253
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
282166
0
14114
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

input:

resume
872862 5028859194772520608
100000
592012
352726
713168
358920
152697
227429
362047
150579
25250
757015
459022
232042
497579
156416
650667
682706
359020
796764
610073
754955
330890
933430
42868
103531
130856
846250
849583
615609
469650
917932
276849
707713
832097
148178
459384
917917
272964
16...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #20:

score: 100
Accepted
time: 7ms
memory: 11804kb

input:

start
100000
98488
113660
714787
629521
117767
260864
370889
996355
766032
216715
661826
948790
617570
848804
9497
133396
588336
642217
1330
120896
200351
475165
875409
314921
552870
352408
338059
484874
753986
620675
324236
695081
606442
585964
793839
62471
22716
249771
69430
778919
257915
46547
24...

output:

98488
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

input:

resume
796017 10614264923536570490
99998
511395
513424
20200
51700
588304
439713
513424
51700
516489
532610
718238
802563
734461
551288
768449
816777
181909
511395
311502
439713
533340
562684
768449
551288
712961
311502
615772
734461
802563
111699
20200
913221
93791
913221
615772
588304
399949
18190...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
516489
0
259558
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 

Test #21:

score: 100
Accepted
time: 6ms
memory: 11776kb

input:

start
99999
252139
517628
929379
211409
510098
517612
484533
935749
142646
41367
256080
823962
855625
964251
622391
660610
102441
373506
348772
348772
318256
602600
971236
825004
831594
470525
484007
185377
218309
660739
735193
396090
823962
386689
97544
513091
893709
521497
873463
198979
256080
779...

output:

252139
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
418077 16962830767701408707
99999
709148
473439
508993
29214
669236
608361
98623
455820
376381
418675
839869
285840
111436
764167
337832
350292
47103
709207
374524
39747
575608
946427
836327
208395
82546
981881
658629
814470
464304
363819
469492
433292
741456
21977
523007
450424
752367
15247
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #22:

score: 100
Accepted
time: 7ms
memory: 11772kb

input:

start
100000
455926
750995
903051
613182
272842
819322
696493
136047
109685
114924
936265
904562
371782
194824
528665
100293
793353
170884
526584
784120
521168
990077
97818
751453
645850
584429
849862
193302
288827
625990
714516
853829
137414
358898
416940
836017
759498
670799
68101
235115
849042
57...

output:

455926
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
247156 1891318815550542208
100000
6170
611174
905913
235546
478370
362508
281450
309264
918470
552035
547119
205908
228862
80752
860032
755733
118018
63327
929281
768166
398121
255188
190075
823126
766773
461522
273713
200605
502893
286886
494543
340341
917032
484807
564125
794007
324094
7445...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #23:

score: 100
Accepted
time: 4ms
memory: 11516kb

input:

start
100000
68266
624214
484353
269449
135510
602966
160020
34440
747457
616904
466802
591950
250598
744721
131281
785497
718880
672530
363731
594834
629037
782441
263843
759653
749201
654978
38658
163113
558805
579678
851296
885087
929839
465855
288762
886784
763218
556089
611850
594356
403622
624...

output:

68266
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

input:

resume
512416 9950872403144380357
99998
263025
44825
711244
127204
975941
927934
951447
783480
427538
200510
410429
671264
994680
838910
408183
749619
800653
463278
562224
820364
299424
279453
378622
36907
374915
637292
664575
145248
12543
163213
658738
145248
710155
243505
102653
450324
862856
5300...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #24:

score: 100
Accepted
time: 3ms
memory: 11568kb

input:

start
100000
325371
170814
366440
69006
768403
259070
95913
809395
717491
3516
171552
169354
993652
613598
528572
849870
814963
672358
250859
645459
462575
428387
237669
910936
290192
916701
839396
350711
206593
788590
793368
483334
961522
855487
430945
676893
48211
573064
500907
833337
911806
651
4...

output:

325371
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
843946 5547147724997590944
99999
256657
96219
133339
393687
313730
900197
1817
45119
640092
8583
421360
171667
95698
906946
811750
44636
731433
300741
233920
805503
779287
133807
175821
877254
68258
388854
211075
165913
135069
994267
828493
322468
383645
888501
723632
660626
797753
636008
700...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #25:

score: 100
Accepted
time: 7ms
memory: 11568kb

input:

start
99999
115395
94587
538403
897723
564885
606177
598848
838949
10553
356321
446534
689926
89721
165139
986352
566786
736962
394383
337693
283650
541411
488121
398551
553188
799828
716527
341970
917677
568548
558178
636848
171256
83673
963298
455804
588947
998689
505360
453841
861469
409912
21262...

output:

115395
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
167658 12556393858315810214
99999
189937
8262
688943
718567
174721
909665
249016
851566
31179
279274
733351
238963
679094
395922
636641
26973
696494
755243
330712
191285
238081
437399
737463
189574
472763
130232
839090
792259
65662
597450
511594
474095
66056
982677
918338
30037
360607
643151
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #26:

score: 100
Accepted
time: 7ms
memory: 11804kb

input:

start
99999
740054
956304
461015
924214
462434
228874
636986
21542
782461
900662
831645
477486
988863
949718
832513
290161
172179
686552
377378
754566
622358
460022
970789
826249
565455
350667
216175
599497
710009
738054
176661
218163
996206
403505
939995
156167
957831
568227
607100
899173
196775
78...

output:

740054
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
433828 12160504724325775534
99999
848830
654373
954223
267227
65473
739000
786260
510309
432942
7179
603861
519912
586293
123225
786260
731515
433408
672035
567070
285072
876143
464167
874076
270475
435714
128420
144050
296284
333341
90111
599823
677081
140594
90003
418503
63471
990332
619795...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #27:

score: 100
Accepted
time: 7ms
memory: 11572kb

input:

start
100000
858735
826365
690220
831531
68461
834868
554047
528612
588949
76263
340817
719752
932561
743539
209520
259228
332553
646708
301885
669256
711791
981652
237362
556448
208225
692992
386198
313482
654512
814491
655660
774128
48827
860713
801796
226661
256777
656470
92208
221150
336852
6319...

output:

858735
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
326756 12632153485082537913
100000
9220
256574
200407
558258
114895
640887
473874
82309
232900
873641
469555
838589
925059
175987
501991
598256
650628
954558
826888
137368
299499
738552
729335
46411
112744
484945
481731
314409
983920
374900
161592
630444
54275
733770
452927
582630
591718
5570...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #28:

score: 100
Accepted
time: 2ms
memory: 11604kb

input:

start
99998
263809
656132
304695
50279
431416
323316
323316
656132
431416
50279
263809
304695
304695
263809
656132
323316
431416
50279
431416
50279
304695
656132
323316
263809
431416
656132
304695
263809
323316
50279
263809
656132
304695
431416
50279
323316
431416
263809
656132
323316
50279
304695
6...

output:

263809
-1
-1
-1
-1
-1
-1
-1
-1
-1
304695
0
304695
-1
-1
-1
-1
-1
-1
-1
-1
-1
263809
0
431416
-1
-1
-1
-1
-1
-1
-1
-1
-1
323316
0
431416
-1
-1
-1
-1
-1
-1
-1
-1
-1
263809
0
656132
-1
-1
-1
-1
-1
-1
-1
-1
-1
431416
0
50279
-1
-1
-1
-1
-1
-1
-1
-1
-1
431416
0
50279
-1
-1
-1
-1
-1
-1
-1
-1
-1
304695
0
3...

input:

resume
168889 5021403157089234782
100000
304695
323316
50279
656132
656132
431416
304695
50279
263809
323316
656132
323316
431416
304695
50279
263809
263809
431416
304695
50279
656132
323316
656132
304695
50279
431416
263809
323316
50279
431416
656132
263809
304695
323316
263809
323316
50279
431416
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
323316
0
656132
-1
-1
-1
-1
-1
-1
-1
-1
-1
323316
0
656132
-1
-1
-1
-1
-1
-1
-1
-1
-1
323316
0
263809
-1
-1
-1
-1
-1
-1
-1
-1
-1
50279
0
656132
-1
-1
-1
-1
-1
-1
-1
-1
-1
431416
0
50279
-1
-1
-1
-1
-1
-1
-1
-1
-1
656132
0
656132
-1
-1
-1
-1
-1
-1
-1
-1
-1
50279
0
263809
-1
-1...

result:

ok 

Test #29:

score: 100
Accepted
time: 6ms
memory: 11572kb

input:

start
99994
184887
688384
193819
505562
189883
483143
970039
388819
912196
956913
780681
241879
180122
916737
791635
708502
215748
111177
16744
740722
740064
923629
892917
423861
508246
475150
165530
226634
105622
971462
386915
720921
434050
846759
126666
797120
800748
264722
438736
117966
134264
16...

output:

184887
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
198335 4267188191307635596
99996
267638
184887
667811
916737
47611
386915
408580
301173
105622
423861
568919
196905
226634
226634
624226
871653
180122
916737
298051
184887
508246
47611
196905
237536
134264
956913
386915
510607
145602
568919
264722
706633
780681
573305
984224
923629
609827
740...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #30:

score: 100
Accepted
time: 3ms
memory: 11604kb

input:

start
99994
887768
264610
623037
691748
602754
988689
455828
746853
662421
329105
748973
845208
494232
72284
192969
902257
907740
53069
177587
726710
418391
169032
534002
574237
235404
613939
987294
125245
303240
123352
376298
239894
841761
99706
672895
863515
637062
75914
139277
660239
453946
54127...

output:

887768
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
247698 12854355515273604327
99998
169032
668944
259911
986242
386093
210504
708169
494232
629331
333643
434457
5267
324938
973177
980208
735454
832207
534002
482846
654166
263796
745253
947767
177587
9277
239703
706577
427834
924330
64896
16607
671320
576623
312033
841761
1955
600949
363003
1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #31:

score: 100
Accepted
time: 3ms
memory: 11576kb

input:

start
100000
333404
37472
654393
182613
37992
624401
939999
390509
244589
488059
832375
61105
599684
682654
163207
438686
735976
70996
708822
983562
993868
539328
60518
872175
256075
87909
345970
2001
531669
395758
95562
857148
554644
842459
463542
565647
3624
465257
413702
878812
750533
163187
9177...

output:

333404
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
253690 1153370655565198461
99996
669793
965792
56838
878812
684779
875641
979777
648532
7912
616850
159683
721901
333418
603788
242875
554644
979776
66812
499183
89351
870749
225086
988365
159922
361467
505268
934095
599843
36565
37992
956670
259128
460377
549713
776878
176598
747043
54461
21...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #32:

score: 100
Accepted
time: 6ms
memory: 11684kb

input:

start
99994
543640
489661
255858
433176
485629
197129
896121
714696
850723
144356
441813
203899
988142
395063
108777
404610
383288
686938
266867
88727
244946
279082
176046
710195
454942
121666
375579
616524
658810
44932
181311
104265
376840
734895
315411
497722
17930
592987
460951
683604
959149
7297...

output:

543640
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
267694 4011631792903494692
100000
825861
350567
789889
800419
187616
684329
591178
445463
737237
257412
391256
273811
336492
618269
900291
74119
224378
105735
847975
47419
463101
688327
814181
805017
387071
725246
824503
469891
74332
419691
668489
715975
144769
818079
761240
516706
290809
467...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #33:

score: 100
Accepted
time: 8ms
memory: 11572kb

input:

start
99997
203369
312464
965080
272620
857569
126210
872488
865360
343744
255970
628893
529958
183758
875970
968303
886887
707666
403277
155956
203767
867258
34634
406479
786830
37142
9703
928812
908876
995005
755987
261836
889989
364047
289822
945970
740232
283515
402826
729689
561160
839374
28565...

output:

203369
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
16429 929982075189532351
99995
441809
932652
683436
920594
267457
959358
861254
538566
172663
623205
811462
115762
268952
326650
713393
376499
344882
529486
867258
144173
470122
827099
402649
447702
663665
956437
37913
482546
517610
78216
300266
320204
883747
509660
384281
100245
817151
67005...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #34:

score: 100
Accepted
time: 3ms
memory: 11572kb

input:

start
99994
410936
979326
575242
131985
477352
603362
997571
171355
199505
495481
9106
561542
921563
129261
732521
462428
66391
253973
796050
217349
491183
376961
312110
350575
86541
703158
479513
735393
51922
456189
414761
527327
48902
320098
934749
679641
293061
12041
931624
184532
796684
86442
32...

output:

410936
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
727189 13282090135944543693
99998
543253
618307
440410
724267
579255
71914
883831
710431
233584
466268
373169
193291
35815
566890
628550
144527
256321
721204
394964
512951
396698
157245
865248
906944
549325
39467
916256
185040
43242
483909
956447
855188
793269
262941
275877
4815
916509
336812...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #35:

score: 100
Accepted
time: 7ms
memory: 11804kb

input:

start
99996
727783
607261
63171
949130
980500
75229
158615
865538
119761
176088
204882
714637
430224
222381
463704
184888
348275
657155
656198
115016
130510
731187
382346
434069
490276
227990
582032
428931
675009
99543
213047
301800
906141
524470
181017
453251
179509
954878
801375
155687
618057
8570...

output:

727783
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
624656 9808040662831263192
99996
108147
480745
469714
479209
130584
939163
449927
998523
860959
350118
799347
271064
810027
492565
395464
790009
571342
978825
220583
637172
320229
588405
652376
739029
277980
803207
776302
70692
902710
752350
537146
822116
938864
574843
236692
685032
188817
79...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #36:

score: 100
Accepted
time: 7ms
memory: 11772kb

input:

start
99998
933646
554173
345184
994611
715473
773844
869293
139690
96317
463511
210032
452622
30569
909927
105568
65163
695673
664610
667940
18196
335039
652358
588430
492921
563679
411104
656046
420733
297728
156796
379853
722687
89377
258027
914390
677848
933937
320455
64261
376868
673512
499678
...

output:

933646
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
113419 18005476156591130251
99995
654666
592919
541020
646631
428224
118524
458173
988100
586030
90715
965268
589928
881141
591029
430526
896886
393663
140147
264849
171048
909441
140654
557645
841841
599673
861591
568098
83369
842907
166204
747144
944919
698001
743791
989264
767208
844566
16...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #37:

score: 100
Accepted
time: 7ms
memory: 11568kb

input:

start
99998
247014
809683
821712
428536
187592
828719
372441
802500
727197
359106
969931
405871
793313
52426
818102
855891
996929
487006
426796
371857
809874
761594
961867
960127
83849
486273
834951
163411
924892
179364
675318
937658
752103
584916
984593
234471
372333
259137
624815
148053
534867
135...

output:

247014
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
655629 1307291461978937411
99996
298975
719826
936640
323763
103340
475812
172532
248030
976990
603510
660125
649327
876961
344513
277922
893568
611300
283001
285358
389188
433006
764414
784293
458213
944686
842685
707210
539064
37100
924309
41117
355012
585100
358025
568260
307524
656997
570...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #38:

score: 100
Accepted
time: 3ms
memory: 11604kb

input:

start
100000
262630
97175
890863
510401
724579
565188
662361
89982
771540
946389
240257
46313
992883
364353
775560
7589
149261
948261
291095
316386
706040
57805
790307
681253
921626
406994
471478
577440
297778
544127
429733
770856
650650
4335
858801
593767
618773
560456
135732
55787
110471
384878
11...

output:

262630
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
560989 14978097671610975729
3
795822
306163
528599

output:

306163
0
528599

result:

ok 

Test #39:

score: 100
Accepted
time: 3ms
memory: 11812kb

input:

start
5
555978
725868
980889
315278
208665

output:

555978
-1
-1
-1
-1
688040 11576978087426236917

input:

resume
688040 11576978087426236917
100000
615574
389263
838294
873481
89742
443962
993935
442736
787592
96532
786319
845992
700392
610545
641301
134070
126756
955631
247510
311733
309077
659397
413609
848628
183479
599903
563869
404825
14616
329255
559469
482798
666927
934272
10270
632857
790061
359...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #40:

score: 100
Accepted
time: 7ms
memory: 11576kb

input:

start
12345
525838
676167
632315
183052
98180
154876
355933
658192
431587
928002
327393
544008
609168
431218
962386
577470
1926
883046
853842
974147
762473
246092
393316
35079
440174
197789
858592
164639
942994
676886
488627
303821
611690
963062
680182
464178
687587
125138
650353
609079
974664
86773...

output:

525838
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
989396 18353616595838016674
100000
158840
568152
106647
596292
650083
146015
38320
128365
515844
546754
645988
287714
689378
665695
457991
46073
39795
162696
102735
341082
531354
307364
968263
887669
782702
324808
722860
135500
317447
279832
241709
215939
354104
889396
761465
343802
507989
84...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #41:

score: 100
Accepted
time: 5ms
memory: 11572kb

input:

start
100000
900001
900002
900003
900004
900005
900006
900007
900008
900009
900010
900011
900012
900013
900014
900015
900016
900017
900018
900019
900020
900021
900022
900023
900024
900025
900026
900027
900028
900029
900030
900031
900032
900033
900034
900035
900036
900037
900038
900039
900040
900041
...

output:

900001
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
195040 17495242305744111081
100000
1000000
999999
999998
999997
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
99996...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 

Test #42:

score: 100
Accepted
time: 5ms
memory: 11540kb

input:

start
100000
900001
900002
900003
900004
900005
900006
900007
900008
900009
900010
900011
900012
900013
900014
900015
900016
900017
900018
900019
900020
900021
900022
900023
900024
900025
900026
900027
900028
900029
900030
900031
900032
900033
900034
900035
900036
900037
900038
900039
900040
900041
...

output:

900001
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

input:

resume
195040 17495242305744111081
100000
900001
900002
900003
900004
900005
900006
900007
900008
900009
900010
900011
900012
900013
900014
900015
900016
900017
900018
900019
900020
900021
900022
900023
900024
900025
900026
900027
900028
900029
900030
900031
900032
900033
900034
900035
900036
900037...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok