QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#585630#9260. Raiffeisenbank Logistics3un_larryfuncAC ✓964ms245856kbC++202.0kb2024-09-23 21:35:182024-09-23 21:35:19

详细

Test #1:

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

input:

1
4 3
2 1 1
2 3 2
4 3 3

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

2
4 3
2 1 1
2 3 2
4 3 2
8 9
1 2 5
2 3 10
4 3 15
4 5 20
5 8 25
1 6 2
6 5 30
7 6 3
8 7 4

output:

-1
1

result:

ok 2 number(s): "-1 1"

Test #3:

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

input:

8
2 1
1 2 1
2 1
2 1 1
2 1
1 1 1
2 1
2 2 1
2 1
1 2 1000000000
2 1
2 1 1000000000
2 1
1 1 1000000000
2 1
2 2 1000000000

output:

0
1
-1
-1
0
1
-1
-1

result:

ok 8 numbers

Test #4:

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

input:

1
2 1
1 2 1

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 4ms
memory: 3564kb

input:

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

output:

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

result:

ok 1000 numbers

Test #6:

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

input:

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

output:

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

result:

ok 1000 numbers

Test #7:

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

input:

1000
10 10
7 10 3
5 5 1
4 9 2
3 4 2
1 4 3
9 6 3
10 1 2
5 10 1
10 8 1
1 7 1
10 10
10 1 1
4 7 3
10 7 2
10 10 2
3 10 1
5 10 2
6 2 3
2 1 3
5 1 1
1 6 2
10 10
6 2 2
7 3 3
5 5 3
5 6 2
6 5 1
7 10 3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1
-1
0
-1
-1
...

result:

ok 1000 numbers

Test #9:

score: 0
Accepted
time: 5ms
memory: 3864kb

input:

1000
10 10
5 3 21
1 6 60
3 10 31
7 9 51
10 7 64
5 6 85
3 4 85
5 1 7
5 3 52
1 7 17
10 10
1 1 90
2 9 78
9 2 82
9 9 29
2 7 67
8 8 44
7 9 87
8 3 3
9 5 32
5 8 15
10 10
2 8 22
3 2 97
7 7 34
1 6 43
5 9 24
4 7 35
3 3 48
9 4 33
5 10 93
1 7 65
10 10
5 4 85
5 1 40
8 9 48
7 1 57
10 10 69
2 2 69
6 4 14
8 4 43
10...

output:

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

result:

ok 1000 numbers

Test #10:

score: 0
Accepted
time: 5ms
memory: 3624kb

input:

1000
10 10
10 10 268155137
5 10 540061009
1 10 110627680
1 4 533692575
3 5 10438095
6 7 730490278
6 2 985939776
8 10 500039201
1 9 185735931
4 2 729538420
10 10
8 1 326383784
5 3 726281100
4 6 279162422
4 4 243297959
1 2 984988531
3 10 856724546
2 4 627158366
4 5 880246199
9 1 675003875
7 7 76366643...

output:

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

result:

ok 1000 numbers

Test #11:

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

input:

1000
10 20
8 8 1
5 1 1
5 3 1
2 4 1
6 9 1
10 7 1
6 10 1
4 4 1
7 7 1
2 10 1
1 8 1
7 6 1
4 1 1
6 4 1
6 1 1
8 6 1
4 6 1
9 3 1
4 2 1
4 10 1
10 20
9 10 1
8 1 1
3 1 1
3 6 1
7 1 1
2 2 1
2 10 1
8 5 1
8 2 1
2 1 1
4 9 1
3 8 1
2 10 1
1 7 1
7 2 1
3 6 1
10 1 1
9 6 1
7 5 1
4 3 1
10 20
9 3 1
9 1 1
9 3 1
10 10 1
9 1...

output:

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

result:

ok 1000 numbers

Test #12:

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

input:

1000
10 20
6 1 2
6 7 2
9 3 2
2 6 2
1 5 2
9 8 2
2 2 1
5 10 2
8 5 2
4 2 1
2 10 2
8 7 1
8 7 2
8 10 1
3 8 2
3 10 2
4 9 2
5 8 1
8 7 2
7 4 2
10 20
6 9 1
10 6 2
7 9 1
8 1 1
4 7 2
10 10 1
9 8 2
3 1 2
2 2 1
5 7 2
8 7 1
1 8 2
8 2 1
5 5 2
5 1 2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test #14:

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

input:

1000
10 20
4 4 7
8 2 9
9 8 2
4 4 7
9 4 8
4 2 10
2 1 8
3 5 10
8 8 8
5 7 9
5 3 2
4 9 7
5 3 2
1 6 5
3 1 10
4 7 4
9 3 4
4 7 7
5 8 8
8 10 1
10 20
6 1 10
8 2 10
4 5 2
6 4 10
1 6 8
8 9 8
6 7 10
8 2 9
1 3 4
6 4 1
5 1 3
4 8 4
1 7 7
5 3 7
1 9 2
9 2 5
5 6 3
2 5 8
1 4 10
3 9 5
10 20
2 7 6
4 8 3
6 4 9
1 4 10
10 ...

output:

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

result:

ok 1000 numbers

Test #15:

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

input:

1000
10 20
2 4 98
7 8 21
7 1 36
6 1 61
4 2 77
1 3 60
5 4 6
6 6 9
4 4 7
7 10 76
4 6 49
6 3 44
3 10 23
9 4 12
7 5 15
2 1 7
3 3 83
4 7 79
8 1 93
10 6 96
10 20
5 5 31
3 8 37
8 8 59
1 8 33
1 9 94
7 7 73
1 9 24
10 3 97
9 5 36
3 1 73
6 3 46
4 2 83
4 4 98
7 7 96
5 10 60
5 2 76
5 2 61
6 4 29
1 10 99
6 3 92
1...

output:

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

result:

ok 1000 numbers

Test #16:

score: 0
Accepted
time: 7ms
memory: 3628kb

input:

1000
10 20
9 8 326353980
1 10 321178299
4 8 970616710
4 9 550923176
8 9 682488932
10 6 752852755
5 10 399703822
10 10 207683413
7 9 84451826
7 8 820433227
7 5 97884128
6 7 1405220
1 5 287655030
8 9 868446569
4 1 421832399
9 4 913601101
2 9 361785960
9 3 425625400
3 9 1891923
8 1 112588430
10 20
6 9 ...

output:

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

result:

ok 1000 numbers

Test #17:

score: 0
Accepted
time: 11ms
memory: 3508kb

input:

1000
10 50
10 1 1
1 5 1
4 1 1
2 7 1
8 4 1
2 10 1
1 4 1
1 10 1
9 6 1
10 6 1
7 7 1
1 6 1
4 3 1
1 5 1
5 4 1
9 10 1
9 4 1
2 6 1
10 10 1
2 10 1
8 1 1
4 6 1
4 4 1
3 6 1
6 1 1
6 5 1
2 7 1
9 6 1
7 3 1
5 4 1
3 10 1
3 1 1
7 7 1
1 5 1
5 7 1
4 8 1
1 6 1
4 3 1
2 10 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ted
time: 17ms
memory: 3632kb

input:

1000
10 50
6 6 3
10 3 3
1 3 1
7 10 2
10 8 1
8 4 3
8 4 2
9 4 1
1 5 3
3 3 2
7 3 1
8 4 2
1 3 3
5 9 3
2 7 1
9 4 2
4 6 1
8 9 1
7 10 3
2 8 1
1 5 3
3 8 2
4 4 3
7 3 2
2 4 2
6 1 2
1 7 1
9 1 1
1 5 3
10 1 3
7 10 2
2 10 3
6 4 2
8 1 3
4 2 2
3 5 3
9 3 1
9 8 1
3 8 3
5 2 2
7 10 1
6 4 3
10 3 2
1 4 1
7 8 2
8 4 2
9 8 ...

output:

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

result:

ok 1000 numbers

Test #20:

score: 0
Accepted
time: 23ms
memory: 3580kb

input:

1000
10 50
5 4 5
4 7 8
10 9 4
6 7 10
9 2 3
2 3 9
5 7 10
2 6 4
4 4 8
9 3 9
1 9 6
2 3 6
8 6 4
2 9 9
9 9 7
4 2 6
9 6 9
5 2 6
1 6 9
6 5 6
5 6 1
4 5 7
6 8 9
2 2 4
3 5 3
6 8 2
4 5 5
2 1 9
3 4 7
10 8 5
1 2 10
9 9 7
4 10 5
10 1 8
10 1 6
7 10 8
10 4 10
9 5 2
10 4 9
8 8 5
3 1 7
6 10 5
4 8 1
6 8 6
6 2 7
5 6 5
...

output:

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

result:

ok 1000 numbers

Test #21:

score: 0
Accepted
time: 26ms
memory: 3576kb

input:

1000
10 50
6 5 76
2 8 63
7 8 83
4 9 100
7 3 28
7 7 60
10 7 8
10 1 49
8 4 16
3 5 51
6 9 84
6 1 43
7 7 36
9 4 97
7 2 39
4 10 41
3 6 68
4 3 1
7 8 53
4 2 74
8 5 5
3 7 63
3 5 38
6 7 25
5 9 83
7 3 85
1 5 72
5 2 15
5 1 51
7 8 56
7 5 13
1 7 98
1 1 17
3 3 26
3 3 19
1 9 10
5 4 17
10 10 56
3 1 90
1 10 42
3 1 2...

output:

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

result:

ok 1000 numbers

Test #22:

score: 0
Accepted
time: 28ms
memory: 3632kb

input:

1000
10 50
2 2 954153759
1 3 283444488
8 10 897162377
6 2 701352810
5 8 872948443
6 10 320895294
10 9 697730752
5 4 375661090
3 4 673334850
6 9 215515206
10 7 977251708
6 1 888046403
5 2 292147356
9 9 840382008
3 10 430429980
6 8 921004331
4 10 298467905
7 1 160104863
10 3 444341972
10 4 653051505
9...

output:

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

result:

ok 1000 numbers

Test #23:

score: 0
Accepted
time: 63ms
memory: 3892kb

input:

1000
10 500
9 9 1
5 1 1
3 3 1
1 1 1
2 1 1
6 10 1
4 6 1
2 4 1
3 7 1
8 5 1
8 4 1
7 10 1
6 2 1
3 5 1
8 9 1
5 3 1
5 1 1
4 2 1
10 8 1
3 8 1
6 3 1
5 2 1
5 3 1
6 3 1
4 6 1
8 1 1
6 8 1
10 7 1
1 5 1
9 2 1
6 10 1
8 6 1
8 10 1
3 10 1
3 2 1
1 3 1
2 8 1
9 3 1
8 8 1
8 1 1
3 2 1
10 8 1
1 1 1
1 7 1
4 7 1
8 3 1
6 10...

output:

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

result:

ok 1000 numbers

Test #24:

score: 0
Accepted
time: 79ms
memory: 3628kb

input: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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 numbers

Test #26:

score: 0
Accepted
time: 126ms
memory: 3864kb

input:

1000
10 500
3 8 7
2 6 10
9 1 10
6 7 1
10 10 6
7 1 6
1 5 10
1 8 9
8 1 7
8 1 3
3 7 8
8 10 1
3 1 1
2 9 10
7 9 9
1 4 10
7 5 9
8 10 2
9 9 9
9 10 7
6 5 7
9 4 8
9 3 3
5 4 5
1 9 3
8 5 9
10 5 10
5 4 4
2 4 10
7 6 9
1 6 4
6 10 10
10 10 4
8 7 8
4 4 9
5 7 4
5 10 9
2 2 8
8 8 3
7 7 1
1 6 4
7 8 1
5 2 10
4 9 1
9 10 ...

output:

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

result:

ok 1000 numbers

Test #27:

score: 0
Accepted
time: 245ms
memory: 3952kb

input:

1000
10 500
4 6 30
2 6 44
4 4 52
5 3 43
7 4 18
1 9 46
3 7 9
3 6 83
9 6 58
3 6 58
9 8 100
10 7 62
3 5 64
5 5 53
6 8 95
1 6 12
1 1 72
10 9 93
4 2 82
8 8 73
4 8 32
9 3 92
5 2 75
4 1 92
10 2 83
10 3 57
9 10 13
3 7 37
6 1 100
9 3 12
7 3 67
6 6 14
4 8 86
8 2 4
4 3 8
7 6 15
10 8 56
6 8 98
4 5 30
7 7 36
1 6...

output:

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

result:

ok 1000 numbers

Test #28:

score: 0
Accepted
time: 288ms
memory: 4024kb

input:

1000
10 500
8 9 67526824
5 4 559064935
10 5 4911091
10 1 665435421
10 9 676899734
7 1 937378183
8 5 573246092
4 7 989380774
4 6 200810178
7 1 416005093
8 8 742684190
1 10 268750539
2 5 718281171
1 8 934536165
1 5 814664163
2 7 237449715
2 1 203051765
6 7 306356562
10 3 428234841
3 1 760994730
10 2 7...

output:

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

result:

ok 1000 numbers

Test #29:

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

input:

1000
500 500
363 349 1
362 206 1
163 390 1
137 172 1
302 114 1
71 291 1
174 386 1
290 118 1
455 251 1
221 39 1
349 64 1
496 62 1
385 170 1
391 24 1
266 372 1
86 223 1
3 209 1
336 410 1
408 288 1
19 470 1
110 356 1
66 95 1
156 271 1
220 405 1
348 367 1
188 485 1
1 499 1
148 160 1
273 394 1
227 401 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 1000 numbers

Test #30:

score: 0
Accepted
time: 221ms
memory: 3760kb

input:

1000
500 500
268 243 2
164 390 1
155 185 1
45 113 1
214 25 1
469 95 2
263 38 1
59 179 2
353 494 2
203 171 1
240 167 2
135 496 1
252 77 2
35 403 1
86 257 1
38 370 1
341 328 1
226 268 1
284 321 1
143 8 1
317 179 2
120 124 1
265 78 2
447 80 2
336 14 1
154 249 1
227 90 2
137 390 1
227 186 1
345 108 1
26...

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 1000 numbers

Test #31:

score: 0
Accepted
time: 230ms
memory: 3780kb

input:

1000
500 500
421 241 2
100 61 2
388 163 1
422 52 1
488 175 2
272 57 1
392 97 2
265 460 2
140 292 3
29 58 1
364 328 3
139 231 3
354 453 1
45 484 1
197 423 1
9 257 2
275 359 2
22 160 1
279 54 1
197 206 3
268 384 2
85 308 1
372 164 2
340 282 1
348 130 2
67 448 2
66 452 2
79 418 3
332 388 3
217 369 2
12...

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 1000 numbers

Test #32:

score: 0
Accepted
time: 240ms
memory: 3884kb

input:

1000
500 500
143 491 2
362 354 3
485 14 4
325 343 1
209 342 1
192 472 3
295 6 1
178 387 4
246 328 1
131 314 1
81 453 2
405 283 3
351 348 1
178 256 4
463 405 4
181 32 2
408 249 3
488 292 4
4 288 1
48 206 2
215 17 1
14 464 3
463 135 4
10 40 4
78 357 4
234 367 4
467 455 4
357 355 2
424 214 2
88 353 2
3...

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
-1...

result:

ok 1000 numbers

Test #33:

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

input:

1000
500 500
140 313 3
155 280 5
197 292 4
234 230 2
348 46 2
269 194 5
434 202 4
33 311 3
152 335 1
384 145 3
235 127 4
370 147 2
444 328 1
127 2 3
357 189 4
255 141 5
460 386 2
398 138 5
326 417 3
51 108 1
22 33 4
251 390 2
79 74 1
215 245 1
482 366 1
253 449 1
460 25 4
318 157 4
380 336 2
225 356...

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
2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 1000 numbers

Test #34:

score: 0
Accepted
time: 400ms
memory: 32900kb

input:

5
10000 100000
16 3559 468695643
7133 1854 827377604
2253 8986 212718926
3378 8735 205907497
3784 3272 98819139
5961 1839 898392689
4722 371 109250145
8884 4871 589883888
7498 9813 70864069
9475 6017 175126069
2932 4557 863780576
7285 6064 122334857
5448 5260 360605203
2995 6162 705458859
9806 2832 ...

output:

1
0
2
0
0

result:

ok 5 number(s): "1 0 2 0 0"

Test #35:

score: 0
Accepted
time: 382ms
memory: 32816kb

input:

5
10000 100000
400 1662 499032381
6939 2059 486853387
8062 4311 263485029
6906 9144 898349721
1374 9791 287537913
1401 2514 179426639
3206 356 654913984
955 4491 102066327
3824 2238 428099250
5030 4171 796495242
3176 8123 228296196
1660 5633 794625946
4996 4363 891788658
4221 4267 717537153
5092 647...

output:

1
0
2
1
1

result:

ok 5 number(s): "1 0 2 1 1"

Test #36:

score: 0
Accepted
time: 405ms
memory: 32836kb

input:

5
10000 100000
9526 8284 30390295
2776 8832 185094918
939 7505 922941741
5631 7025 869203187
8618 8178 304297509
4573 6637 697002478
7831 8738 160865264
8640 1154 975091136
3872 1182 637499754
9369 8403 47264467
6368 2555 483838225
7177 4894 244976652
9845 1265 564379654
2955 1436 118973925
3645 199...

output:

0
1
1
0
1

result:

ok 5 number(s): "0 1 1 0 1"

Test #37:

score: 0
Accepted
time: 519ms
memory: 153012kb

input:

1
100000 500000
34635 46033 243840177
89991 69694 442882506
19968 21610 887963959
59100 4326 518891263
32030 66602 905457084
6365 4377 378500516
35716 52072 375354442
83763 63671 748057938
90167 71718 314322061
20985 57673 399305781
33422 9344 54429249
8621 10927 88073233
24414 18967 895092185
91512...

output:

-1

result:

ok 1 number(s): "-1"

Test #38:

score: 0
Accepted
time: 528ms
memory: 152712kb

input:

1
100000 500000
15188 94877 126956305
36064 18948 613736176
54124 38302 322768646
61948 64766 801195445
69649 93035 698032982
45412 52100 455948433
23657 16312 543752460
82338 71180 928014228
84388 81926 336635918
20855 4689 124954834
75713 19615 821948475
70517 69931 455049369
11652 49042 460926915...

output:

-1

result:

ok 1 number(s): "-1"

Test #39:

score: 0
Accepted
time: 517ms
memory: 152848kb

input:

1
100000 500000
52638 76426 305039729
14841 68201 344398357
20983 22290 197764822
54396 25205 378466923
96868 95277 340865776
25674 24014 678620542
87405 89065 712150478
24017 78689 548162006
45905 24838 63982479
20726 94809 705379695
85300 72989 734691893
73629 72040 116992802
66185 79117 26761645
...

output:

-1

result:

ok 1 number(s): "-1"

Test #40:

score: 0
Accepted
time: 563ms
memory: 229136kb

input:

1
500000 500000
59280 54906 439822256
429265 418258 621212182
218147 211795 205467984
164946 71245 957403153
481375 344334 382889209
206719 295309 525844696
195710 220464 534488515
49094 402808 390137503
110467 267533 689219374
466476 328515 301654731
60840 13684 148387915
395867 144861 350257604
45...

output:

-1

result:

ok 1 number(s): "-1"

Test #41:

score: 0
Accepted
time: 552ms
memory: 229144kb

input:

1
500000 500000
339833 103751 322938384
440746 267512 646841660
152303 395783 935239967
467793 107493 239707335
451698 413871 25722003
486981 299927 453549509
483651 484705 407919237
147669 10317 865061089
171984 353549 711533231
233642 318636 882079592
370427 491251 61131333
233571 414266 717233740...

output:

-1

result:

ok 1 number(s): "-1"

Test #42:

score: 0
Accepted
time: 573ms
memory: 229168kb

input:

1
500000 500000
344579 152595 795989104
419522 359869 522728034
86458 79771 810236143
27537 367932 522011518
146214 240305 963522093
426027 80354 530997427
80103 314354 281349959
22052 117827 190241570
266205 163757 438879792
33513 32948 312761349
488526 277329 533683263
360875 473271 379177172
1284...

output:

-1

result:

ok 1 number(s): "-1"

Test #43:

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

input:

1
40003 80000
35719 1310 38202
835 12806 47060
3603 7710 11806
14153 3125 43071
4939 15539 4841
33565 14175 16271
20550 10855 10018
32124 23731 12555
1753 13312 56596
25501 38087 44821
7833 1310 37857
29811 1310 31956
1310 26094 31445
1088 1310 31689
7975 26106 41605
3119 1310 33900
1310 30057 37747...

output:

9839

result:

ok 1 number(s): "9839"

Test #44:

score: 0
Accepted
time: 96ms
memory: 37592kb

input:

1
50003 100000
18947 6618 51034
14403 28620 24960
18275 31280 47766
16886 18275 49915
29925 18275 30981
11415 43240 70297
18528 15339 7714
2109 19043 67335
18275 2484 41363
40355 18275 29750
2460 18275 34885
18275 37437 46105
20365 46207 18672
14376 18275 35112
10321 18275 40154
48804 11937 23830
84...

output:

24972

result:

ok 1 number(s): "24972"

Test #45:

score: 0
Accepted
time: 769ms
memory: 172192kb

input:

1
250003 500000
211077 238099 171793
99544 223109 119398
220964 37598 352288
76015 238099 126488
181513 37313 94127
162769 1217 348890
12232 238099 232571
238099 159232 144936
211053 139552 56322
151055 238099 177414
106292 238099 222048
22435 127764 60070
207734 142160 359958
238099 111969 135550
5...

output:

62195

result:

ok 1 number(s): "62195"

Test #46:

score: 0
Accepted
time: 964ms
memory: 171360kb

input:

1
250003 500000
117976 133059 178785
133059 240784 155465
173322 133059 173232
234970 67691 337673
97726 157211 367826
95726 133059 131100
133059 85217 171806
78769 159969 94987
87937 133059 128283
133059 28720 204220
7384 151425 341511
191878 133059 151897
133059 36458 167200
133059 153425 159138
1...

output:

124973

result:

ok 1 number(s): "124973"

Test #47:

score: 0
Accepted
time: 921ms
memory: 171656kb

input:

1
250003 500000
51871 87116 145873
87116 1573 215750
87116 57519 163372
113771 97363 79054
53216 113905 263758
140120 233744 366400
87116 157990 191401
87116 199403 213791
159542 65483 346605
223786 19461 314038
232150 58329 32081
130102 43124 67742
25626 56922 305977
135831 163061 283421
225000 871...

output:

125003

result:

ok 1 number(s): "125003"

Test #48:

score: 0
Accepted
time: 228ms
memory: 234420kb

input:

1
500000 499999
1 2 326
2 3 1079
3 4 1461
4 5 2998
5 6 5451
6 7 5789
7 8 8341
8 9 8689
9 10 10894
10 11 12835
11 12 13589
12 13 15157
13 14 19386
14 15 27446
15 16 27769
16 17 30808
17 18 31370
18 19 31765
19 20 32270
20 21 32285
21 22 32317
22 23 33630
23 24 34734
24 25 36925
25 26 39867
26 27 4164...

output:

0

result:

ok 1 number(s): "0"

Test #49:

score: 0
Accepted
time: 250ms
memory: 234512kb

input:

1
500000 499999
499999 500000 999998868
499998 499999 999997855
499997 499998 999996016
499996 499997 999993636
499995 499996 999992710
499994 499995 999986263
499993 499994 999984321
499992 499993 999983777
499991 499992 999983353
499990 499991 999981342
499989 499990 999975363
499988 499989 999974...

output:

0

result:

ok 1 number(s): "0"

Test #50:

score: 0
Accepted
time: 679ms
memory: 233836kb

input:

1
500000 499999
212450 212451 425201388
2384 2385 4878863
174315 174316 348485072
313186 313187 626806935
201854 201855 403967559
254356 254357 509524140
255640 255641 512015450
151871 151872 303240136
20039 20040 39830835
449344 449345 898732688
434659 434660 869083908
299928 299929 599946698
33406...

output:

0

result:

ok 1 number(s): "0"

Test #51:

score: 0
Accepted
time: 246ms
memory: 237736kb

input:

1
500000 499999
2 1 1370
3 2 2716
4 3 3800
5 4 3868
6 5 10907
6 7 16629
7 8 19394
8 9 19417
9 10 19650
11 10 21281
11 12 24374
12 13 26567
14 13 27183
15 14 27468
16 15 27516
16 17 29364
17 18 30326
18 19 34525
20 19 35282
20 21 44815
21 22 48545
23 22 48557
23 24 51805
25 24 52108
25 26 62133
26 27...

output:

250083

result:

ok 1 number(s): "250083"

Test #52:

score: 0
Accepted
time: 242ms
memory: 238308kb

input:

1
500000 499999
500000 499999 999998265
499998 499999 999995242
499997 499998 999994536
499997 499996 999994473
499995 499996 999992892
499995 499994 999989139
499994 499993 999988969
499993 499992 999987287
499992 499991 999985670
499991 499990 999984500
499990 499989 999981354
499988 499989 999980...

output:

250028

result:

ok 1 number(s): "250028"

Test #53:

score: 0
Accepted
time: 673ms
memory: 238000kb

input:

1
500000 499999
402287 402288 804403202
84856 84855 169338328
198083 198082 395691589
442999 442998 885886302
339037 339038 677247956
404583 404584 808921280
474484 474483 948677462
317825 317824 634415317
294043 294042 586680173
456519 456518 912892209
460728 460727 921501769
117702 117703 23475622...

output:

250043

result:

ok 1 number(s): "250043"

Test #54:

score: 0
Accepted
time: 208ms
memory: 245856kb

input:

1
500000 499999
2 1 6989
3 2 7016
4 3 9994
5 4 10215
6 5 13154
7 6 14283
8 7 20769
9 8 20948
10 9 21544
11 10 23728
12 11 24401
13 12 25752
14 13 29683
15 14 32491
16 15 32594
17 16 34086
18 17 37991
19 18 41176
20 19 41609
21 20 42975
22 21 45016
23 22 46922
24 23 48845
25 24 51499
26 25 52280
27 2...

output:

499999

result:

ok 1 number(s): "499999"

Test #55:

score: 0
Accepted
time: 236ms
memory: 245384kb

input:

1
500000 499999
500000 499999 999999889
499999 499998 999999782
499998 499997 999998848
499997 499996 999998824
499996 499995 999995409
499995 499994 999994544
499994 499993 999992791
499993 499992 999989862
499992 499991 999988916
499991 499990 999985725
499990 499989 999981211
499989 499988 999977...

output:

499999

result:

ok 1 number(s): "499999"

Test #56:

score: 0
Accepted
time: 631ms
memory: 245480kb

input:

1
500000 499999
338741 338740 678180393
437033 437032 874877335
499553 499552 999088036
405433 405432 811657036
129348 129347 258992660
458071 458070 916420798
9873 9872 19447139
497312 497311 994645635
467696 467695 935862948
86714 86713 172958814
68511 68510 136388366
466283 466282 933056333
24082...

output:

499999

result:

ok 1 number(s): "499999"

Test #57:

score: 0
Accepted
time: 228ms
memory: 229660kb

input:

1
500000 499999
1 2 239
2 3 1013
3 4 3047
4 5 3720
5 6 5980
6 7 7317
7 8 9838
8 9 15075
9 10 15956
10 11 19152
11 12 19910
12 13 22189
13 14 22769
14 15 23155
15 16 23860
16 17 27421
17 18 31978
18 19 32640
19 20 32822
20 21 35021
21 22 37900
22 23 38368
23 24 44632
24 25 47171
25 26 49488
26 27 518...

output:

-1

result:

ok 1 number(s): "-1"

Test #58:

score: 0
Accepted
time: 220ms
memory: 230216kb

input:

1
500000 499999
499999 500000 999998715
499998 499999 999997502
499997 499998 999997473
499996 499997 999992577
499995 499996 999992053
499994 499995 999991852
499993 499994 999990637
499992 499993 999990176
499991 499992 999988482
499990 499991 999985806
499989 499990 999981215
499988 499989 999978...

output:

-1

result:

ok 1 number(s): "-1"

Test #59:

score: 0
Accepted
time: 681ms
memory: 230176kb

input:

1
500000 499999
393552 393553 787163627
492609 492610 985045953
144107 144108 288280399
52762 52763 105132040
369448 369449 738240515
210674 210675 421137901
459882 459883 920106374
351 352 807137
448988 448989 898190282
190527 190528 380916341
145286 145287 290659053
123135 123136 245773586
216819 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #60:

score: 0
Accepted
time: 202ms
memory: 229796kb

input:

1
500000 499999
1 2 689
2 3 6888
3 4 8206
4 5 12987
6 5 19462
6 7 20593
8 7 20637
9 8 21675
10 9 22699
11 10 31643
12 11 35197
12 13 37798
14 13 39872
15 14 40307
16 15 42179
17 16 43217
17 18 44285
19 18 45184
19 20 47194
21 20 48922
22 21 52733
23 22 54103
23 24 61194
25 24 62123
25 26 62740
27 26...

output:

-1

result:

ok 1 number(s): "-1"

Test #61:

score: 0
Accepted
time: 216ms
memory: 230636kb

input:

1
500000 499999
500000 499999 999999452
499998 499999 999998588
499997 499998 999997878
499997 499996 999993773
499996 499995 999992569
499995 499994 999989266
499994 499993 999988724
499993 499992 999986373
499991 499992 999983773
499991 499990 999983308
499990 499989 999980182
499988 499989 999978...

output:

-1

result:

ok 1 number(s): "-1"

Test #62:

score: 0
Accepted
time: 633ms
memory: 230172kb

input:

1
500000 499999
152948 152949 306628441
404033 404034 808230174
263707 263708 528055149
365049 365048 730281545
176178 176179 352893056
472051 472050 944127686
246551 246552 493846125
277078 277077 554559841
91347 91348 182661783
408268 408267 816662560
357356 357357 715075971
194302 194303 38917939...

output:

-1

result:

ok 1 number(s): "-1"

Test #63:

score: 0
Accepted
time: 203ms
memory: 229696kb

input:

1
500000 499999
2 1 1382
3 2 1629
4 3 2737
5 4 3721
6 5 4647
7 6 5244
8 7 5638
9 8 10853
10 9 11469
11 10 13657
12 11 14229
13 12 14921
14 13 16882
15 14 18434
16 15 19884
17 16 21964
18 17 22770
19 18 25013
20 19 25017
21 20 26105
22 21 28245
23 22 30331
24 23 36880
25 24 40663
26 25 42155
27 26 45...

output:

-1

result:

ok 1 number(s): "-1"

Test #64:

score: 0
Accepted
time: 218ms
memory: 229712kb

input:

1
500000 499999
500000 499999 999998619
499999 499998 999997886
499998 499997 999993725
499997 499996 999990379
499996 499995 999990207
499995 499994 999987393
499994 499993 999985137
499993 499992 999978181
499992 499991 999977975
499991 499990 999977002
499990 499989 999976127
499989 499988 999975...

output:

-1

result:

ok 1 number(s): "-1"

Test #65:

score: 0
Accepted
time: 520ms
memory: 230424kb

input:

1
500000 499999
448141 448140 896578666
87344 87343 175184398
267504 267503 535758017
324245 324244 649415406
424195 424194 848646006
39743 39742 79468846
189826 189825 379860380
458453 458452 916975222
244267 244266 489033609
359049 359048 718356557
302831 302830 606326931
103537 103536 207764710
3...

output:

-1

result:

ok 1 number(s): "-1"

Test #66:

score: 0
Accepted
time: 178ms
memory: 4280kb

input:

508
1042 61
200 590 1
6 763 1
581 966 1
777 594 1
502 90 1
296 758 1
903 535 1
553 560 1
855 907 1
887 903 1
9 804 1
234 410 1
199 990 1
712 72 1
743 163 1
988 1019 1
529 16 1
167 497 1
902 58 1
467 976 1
576 14 1
678 61 1
469 876 1
842 393 1
520 239 1
777 251 1
388 106 1
215 370 1
474 222 1
732 428...

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
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1...

result:

ok 508 numbers

Test #67:

score: 0
Accepted
time: 256ms
memory: 4264kb

input:

528
658 830
244 420 9
170 144 10
650 371 9
100 526 6
294 401 2
320 254 10
453 588 5
57 160 9
266 217 3
389 326 3
640 74 4
438 592 4
423 110 4
336 204 5
571 7 4
299 615 2
321 474 2
571 409 1
383 421 5
563 655 9
61 132 6
259 57 9
51 413 1
655 19 8
583 251 4
403 251 1
126 244 2
551 517 9
523 293 6
541 ...

output:

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

result:

ok 528 numbers

Test #68:

score: 0
Accepted
time: 271ms
memory: 4432kb

input:

505
782 1221
114 313 74
547 307 28
483 733 2
403 764 98
12 628 67
538 504 28
420 543 49
356 22 80
469 395 2
278 46 12
251 736 6
404 237 65
24 41 74
438 732 81
634 404 42
587 615 56
183 355 30
766 434 71
184 72 67
271 720 44
98 444 30
76 580 52
568 159 93
62 364 29
214 779 5
578 300 61
162 659 67
253...

output:

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

result:

ok 505 numbers

Test #69:

score: 0
Accepted
time: 263ms
memory: 4520kb

input:

487
528 947
71 400 998
101 427 772
240 145 189
503 114 630
380 297 168
55 28 614
137 103 701
524 413 431
230 376 359
338 299 224
205 115 407
247 155 446
335 369 787
422 237 430
47 129 215
130 57 689
176 188 234
101 282 203
49 5 362
331 299 838
216 420 363
169 160 732
430 52 693
275 200 947
523 154 4...

output:

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

result:

ok 487 numbers

Test #70:

score: 0
Accepted
time: 189ms
memory: 7296kb

input:

103
2756 1816
1051 179 1
55 2480 1
1374 2380 1
2520 2008 1
24 2111 1
438 554 1
71 1543 1
1201 2400 1
1595 1449 1
2204 883 1
54 1596 1
604 2163 1
1552 1618 1
2260 1836 1
473 2319 1
1477 2407 1
1237 346 1
1164 901 1
2072 617 1
369 1833 1
2224 2673 1
634 255 1
15 2741 1
2536 2387 1
445 2219 1
785 92 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 103 numbers

Test #71:

score: 0
Accepted
time: 274ms
memory: 7712kb

input:

102
5989 6275
4003 444 8
1281 5696 9
2409 1474 1
4815 3523 8
161 4536 2
4828 265 9
3763 2392 8
1398 1377 2
5225 5658 9
2678 319 8
5701 3241 5
1021 5437 7
534 4239 3
3150 2514 8
749 3353 8
2149 3788 9
408 3596 6
5163 5424 5
5927 3627 7
4325 2522 4
334 1111 8
1252 5438 4
1123 2004 6
5835 4375 1
939 54...

output:

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

result:

ok 102 numbers

Test #72:

score: 0
Accepted
time: 280ms
memory: 8372kb

input:

98
7731 1241
414 2001 96
1851 3634 91
3423 687 82
2462 1504 35
1700 2911 61
3625 7066 56
746 6813 28
3268 7158 50
1322 6057 48
6841 5627 28
2406 7565 59
6862 6498 30
4958 4627 98
4994 5220 91
1398 394 94
7292 4618 80
1329 773 38
6460 1910 53
448 7203 70
5096 4603 27
5889 2692 35
3556 5932 94
3734 74...

output:

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

result:

ok 98 numbers

Test #73:

score: 0
Accepted
time: 296ms
memory: 7772kb

input:

107
2601 4326
1105 2107 395
320 2303 964
319 1587 875
1127 1406 430
1664 1571 203
1538 2108 102
1033 1617 774
1607 381 198
143 2294 791
2351 1284 481
1968 2009 910
2097 879 932
705 732 180
2033 1049 461
2128 2330 400
178 325 627
263 682 267
1972 2137 93
587 2585 986
1062 1202 741
1997 1987 804
402 8...

output:

-1
0
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
-1
-1
-1
0
-1
1
-1
0
-1
-1
-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
4
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-...

result:

ok 107 numbers

Test #74:

score: 0
Accepted
time: 219ms
memory: 37980kb

input:

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

output:

0
1
-1
0
-1
-1
-1
0
0
-1
-1
0
-1
-1
0

result:

ok 15 numbers

Test #75:

score: 0
Accepted
time: 315ms
memory: 41176kb

input:

14
220 6
60 12 4
193 75 9
102 109 5
219 58 10
178 108 4
107 116 5
89290 79638
19957 77389 5
55665 65552 3
63021 87817 7
739 8028 8
75957 20562 1
76551 41971 10
33210 7322 10
17197 3864 10
63020 84337 10
48191 60304 5
65695 87885 6
62076 3085 4
82940 80779 4
48653 27540 2
74951 3758 5
50096 49552 9
8...

output:

-1
-1
-1
-1
-1
0
-1
-1
-1
-1
4
-1
-1
-1

result:

ok 14 numbers

Test #76:

score: 0
Accepted
time: 330ms
memory: 36708kb

input:

16
95158 56211
76931 70501 30
405 34377 50
47354 90911 11
33820 8665 30
15655 75894 16
66461 56076 95
27066 45453 69
26255 94028 12
26094 33284 29
77828 59515 52
59908 73219 32
41573 41107 15
58538 47281 89
31279 24636 1
34307 14655 45
45913 61139 66
15043 56624 55
69873 54648 44
61495 16058 24
9432...

output:

-1
0
-1
-1
-1
0
0
0
-1
0
0
-1
-1
0
-1
0

result:

ok 16 numbers

Test #77:

score: 0
Accepted
time: 389ms
memory: 45224kb

input:

18
10055 7708
8863 4581 557
8131 7799 229
2766 6993 351
8098 825 872
1510 8957 666
1459 5256 715
3276 9839 124
824 725 649
5674 895 641
378 2990 499
183 1021 905
4676 5114 273
3738 2442 32
3564 8669 300
1031 8267 763
4284 4909 816
2313 4999 264
8773 6309 110
1081 5849 718
7674 3928 682
3209 8599 790...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
0
0
-1
0
-1

result:

ok 18 numbers

Test #78:

score: 0
Accepted
time: 266ms
memory: 85300kb

input:

8
347175 72376
15522 65229 1
79296 171258 1
230357 70316 1
30501 191679 1
147194 144651 1
241881 192142 1
241773 297973 1
32879 146066 1
242567 231322 1
278353 69233 1
331230 85702 1
3419 342322 1
114358 267321 1
306219 167077 1
81676 125143 1
54146 278169 1
260945 324027 1
340029 77172 1
44915 3254...

output:

-1
-1
-1
0
-1
-1
0
-1

result:

ok 8 numbers

Test #79:

score: 0
Accepted
time: 490ms
memory: 95484kb

input:

7
80508 25899
59836 34649 1
64383 11071 8
56830 48319 8
8812 4902 9
24295 29741 10
35619 54681 3
54031 64789 5
77198 12216 7
69721 39910 4
78326 13406 10
54249 60931 10
2401 60096 8
57757 71035 6
77389 32044 10
39362 36902 6
31651 50026 3
63309 57966 2
79027 51763 6
37700 11179 7
70252 31986 4
74415...

output:

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

result:

ok 7 numbers

Test #80:

score: 0
Accepted
time: 463ms
memory: 81216kb

input:

11
13327 164
4399 10868 94
12450 3558 44
11567 9253 26
1443 8743 16
1519 670 97
12610 6722 5
8620 4922 87
7336 5033 45
7296 2165 94
3687 4514 76
17 7663 10
8317 8311 14
6354 12646 23
10431 1600 36
4445 7773 61
8670 3942 75
3954 1902 20
5221 9577 19
9732 4894 32
11537 5305 73
8541 12469 20
9900 907 5...

output:

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

result:

ok 11 numbers

Test #81:

score: 0
Accepted
time: 576ms
memory: 181172kb

input:

10
283 577
123 41 421
118 75 32
133 32 526
82 240 97
10 48 856
248 34 225
277 139 493
61 58 552
105 64 998
244 91 274
201 177 192
78 274 27
72 83 672
150 206 614
199 100 438
160 196 326
81 262 183
55 37 677
80 172 38
242 69 276
3 154 885
219 93 698
105 63 7
272 159 594
139 96 169
100 163 695
50 245 ...

output:

-1
-1
0
0
-1
1
-1
-1
0
0

result:

ok 10 numbers

Test #82:

score: 0
Accepted
time: 195ms
memory: 32048kb

input:

10
2 71
2 2 989
1 2 660
1 1 176
1 1 753
1 2 500
2 1 566
2 2 797
1 1 732
1 2 729
2 2 225
1 2 503
1 1 615
2 1 511
1 2 410
1 1 444
2 2 177
2 2 318
1 1 128
2 2 740
2 1 140
1 2 745
1 2 335
2 1 60
2 1 757
2 1 293
1 1 359
1 2 174
1 1 454
2 1 503
2 2 403
2 2 21
1 1 254
2 2 596
2 1 117
1 2 883
1 1 686
2 2 57...

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #83:

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

input:

10
3 119
2 1 847
3 2 60
2 1 949
1 2 870
3 2 951
1 2 687
2 3 149
2 1 160
2 1 6
1 3 136
2 2 176
3 2 376
1 1 102
1 2 919
1 3 803
2 1 975
3 2 958
2 2 791
2 2 63
3 1 842
1 3 41
2 1 503
2 3 376
1 1 211
2 3 756
2 1 83
1 3 94
1 2 102
1 3 890
1 3 907
1 1 61
2 2 278
1 1 1
2 3 721
1 1 911
3 3 600
3 3 484
1 3 5...

output:

0
0
0
0
0
0
0
0
0
-1

result:

ok 10 numbers

Test #84:

score: 0
Accepted
time: 209ms
memory: 20764kb

input:

12
3 3873
2 3 408
3 2 615
3 1 78
3 2 228
2 1 167
1 1 363
1 3 46
3 3 178
2 1 274
3 1 882
3 2 789
1 2 791
3 2 610
3 2 601
3 2 142
3 1 937
3 1 542
1 3 455
3 2 379
2 1 98
1 3 699
3 1 329
1 3 328
3 1 16
3 2 109
2 3 238
1 3 831
2 3 749
3 3 481
1 1 370
1 2 91
2 1 382
1 1 181
1 2 173
1 1 175
2 2 182
1 3 548...

output:

0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 12 numbers

Test #85:

score: 0
Accepted
time: 223ms
memory: 32180kb

input:

16
3 31
2 3 79
1 1 13
3 1 619
1 2 324
2 2 580
3 3 265
2 2 963
1 3 185
2 3 526
3 2 758
1 3 3
1 2 88
2 2 105
3 2 566
3 2 856
3 2 406
2 1 1000
3 3 513
2 1 463
3 3 426
1 1 590
1 1 48
1 3 191
2 2 138
2 1 879
3 2 10
2 2 906
1 2 533
2 1 847
2 1 569
3 1 73
5 1
2 5 877
5 5
4 5 441
3 1 361
1 5 391
4 4 222
2 1...

output:

0
-1
0
0
0
0
0
3
0
0
0
0
0
0
0
0

result:

ok 16 numbers

Test #86:

score: 0
Accepted
time: 210ms
memory: 21288kb

input:

19
2 183
2 1 834
1 1 244
1 2 712
2 1 834
1 1 733
2 1 344
1 1 47
1 1 804
1 2 475
2 1 425
1 2 91
2 1 316
2 2 869
1 1 302
2 1 652
1 1 930
1 1 124
2 2 898
2 1 873
1 2 366
1 2 80
1 2 765
2 1 601
2 1 904
1 1 787
1 1 748
2 1 185
1 1 151
2 1 365
2 2 182
2 2 955
1 1 149
2 2 464
2 2 423
1 2 795
2 2 56
1 2 331...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
0
0
-1

result:

ok 19 numbers

Test #87:

score: 0
Accepted
time: 218ms
memory: 24112kb

input:

20
2 2
2 1 600
1 1 868
7 423
2 4 522
1 5 893
5 4 580
2 4 482
3 6 192
4 2 833
7 7 641
2 5 382
1 7 992
6 6 958
2 7 363
6 7 75
2 5 552
2 4 981
6 7 678
7 7 475
2 2 949
1 4 627
5 7 277
2 2 86
3 2 756
2 6 511
6 5 203
4 5 581
3 4 156
7 6 903
6 1 364
6 1 383
3 3 871
6 6 26
5 1 716
1 5 502
2 5 462
6 6 965
2 ...

output:

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

result:

ok 20 numbers

Test #88:

score: 0
Accepted
time: 203ms
memory: 22380kb

input:

10
7 3999
4 6 119
7 2 592
5 7 769
1 3 346
2 1 804
1 3 35
4 5 431
2 6 28
7 7 291
4 3 338
4 4 66
4 5 834
1 3 532
7 3 457
1 7 429
3 1 353
4 7 320
5 6 440
7 1 271
6 6 873
7 2 150
1 2 72
5 1 997
3 3 921
1 6 597
6 4 497
3 5 822
1 5 688
7 3 848
7 3 789
3 7 431
7 3 147
5 3 579
5 6 500
6 1 751
3 6 692
6 2 35...

output:

0
0
-1
0
0
0
0
0
0
0

result:

ok 10 numbers

Test #89:

score: 0
Accepted
time: 217ms
memory: 33636kb

input:

7
3 4
1 1 320
1 2 935
2 3 903
1 2 680
7 147431
1 5 99
6 7 927
1 3 369
6 3 782
3 5 427
4 7 719
5 4 218
7 4 637
6 6 134
7 3 776
3 6 122
1 6 768
6 7 686
2 2 481
7 7 805
1 1 368
6 5 248
3 5 972
3 4 874
2 7 136
4 1 133
1 6 879
4 1 109
4 4 409
1 3 539
6 3 965
2 1 188
5 1 719
7 5 787
3 4 868
1 4 116
6 6 66...

output:

0
0
0
0
0
0
0

result:

ok 7 numbers

Test #90:

score: 0
Accepted
time: 221ms
memory: 26052kb

input:

12
4 319713
3 2 714
2 4 534
2 3 231
2 3 897
4 1 805
3 3 64
2 3 243
4 4 494
4 2 157
2 2 49
1 4 547
3 2 802
2 2 748
1 1 774
4 4 459
2 2 523
4 4 754
3 2 30
3 1 429
2 1 539
2 1 448
4 4 429
4 4 532
2 4 943
2 3 951
3 1 531
4 1 259
2 4 914
1 4 761
1 1 12
2 3 14
3 1 313
2 2 565
2 3 679
1 3 166
3 1 694
4 3 3...

output:

0
0
0
0
-1
0
-1
0
0
0
-1
0

result:

ok 12 numbers

Test #91:

score: 0
Accepted
time: 241ms
memory: 22008kb

input:

15
15 11129
13 1 601
2 8 537
7 10 591
13 14 459
4 12 838
3 15 81
4 9 127
8 11 618
13 12 909
8 12 353
14 12 683
6 1 322
5 6 474
11 12 826
9 2 71
13 15 68
7 8 484
8 11 985
7 11 973
2 5 472
11 11 190
12 12 638
7 14 707
5 7 318
8 1 400
8 9 85
3 5 138
13 6 975
5 14 21
6 2 118
9 2 935
4 4 796
9 11 93
15 3...

output:

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

result:

ok 15 numbers

Test #92:

score: 0
Accepted
time: 248ms
memory: 37044kb

input:

13
11 20
11 5 325
8 8 832
1 6 305
6 3 58
4 9 990
5 1 848
3 6 771
3 2 873
4 6 939
11 7 403
4 8 346
7 5 808
11 4 424
8 9 916
8 5 926
4 6 41
11 9 686
9 4 431
7 9 568
1 1 798
10 3701
6 10 870
7 10 278
7 5 42
5 9 159
2 9 554
5 6 743
8 4 760
8 10 364
4 2 448
7 2 650
8 7 80
7 3 917
5 8 937
2 5 18
7 8 277
4...

output:

-1
0
0
0
0
0
0
0
0
0
0
-1
0

result:

ok 13 numbers

Test #93:

score: 0
Accepted
time: 265ms
memory: 24104kb

input:

11
13 187689
11 10 729
7 2 22
9 13 365
3 8 909
12 11 6
8 7 319
11 6 981
3 10 339
1 3 843
8 7 354
10 1 22
6 12 327
10 9 125
3 3 558
2 1 390
8 9 972
13 9 423
13 2 150
5 13 99
1 1 862
13 7 838
3 3 106
4 6 283
1 11 517
10 1 549
13 11 883
13 5 691
6 6 359
3 7 384
10 11 192
13 5 794
3 7 157
12 2 306
2 4 3...

output:

0
0
0
-1
0
-1
0
0
0
0
0

result:

ok 11 numbers

Test #94:

score: 0
Accepted
time: 292ms
memory: 32628kb

input:

10
27 418
4 12 565
23 10 6
12 12 13
2 9 405
8 4 534
8 2 722
8 22 966
10 27 26
1 17 286
21 3 464
11 12 78
3 25 809
26 17 938
19 22 873
27 15 497
12 11 429
7 8 250
27 7 362
3 10 98
7 27 957
22 6 892
6 26 588
9 16 656
21 1 85
13 13 815
8 10 118
4 26 21
19 2 717
23 1 560
24 7 912
11 13 367
18 27 943
27 ...

output:

0
0
-1
-1
0
0
1
0
0
0

result:

ok 10 numbers

Test #95:

score: 0
Accepted
time: 306ms
memory: 19996kb

input:

14
41 62279
32 24 101
16 21 177
13 27 860
41 17 152
36 7 445
22 6 225
22 7 817
32 6 179
40 19 420
36 29 203
6 37 989
31 19 602
34 1 773
21 13 400
12 35 171
30 22 82
1 27 862
15 13 593
17 6 922
38 18 532
8 22 287
38 40 168
31 41 608
35 34 486
15 35 625
36 41 108
1 6 555
21 29 919
24 32 163
36 29 864
...

output:

0
-1
1
0
0
0
0
-1
-1
0
0
0
0
0

result:

ok 14 numbers

Test #96:

score: 0
Accepted
time: 283ms
memory: 37688kb

input:

14
66 30805
57 23 295
45 54 589
32 59 958
48 65 426
53 1 286
56 19 729
19 1 414
39 26 89
61 63 527
14 65 921
25 18 882
25 42 276
32 17 599
46 21 903
9 47 175
2 50 439
10 28 700
20 61 558
57 13 55
20 27 1000
20 24 698
52 62 392
46 42 231
21 32 536
14 11 720
30 47 945
12 62 864
8 48 623
22 38 66
28 26...

output:

0
0
-1
0
-1
0
0
0
-1
0
0
0
0
-1

result:

ok 14 numbers

Test #97:

score: 0
Accepted
time: 386ms
memory: 31476kb

input:

15
187 91
146 160 753
162 32 868
54 121 336
17 24 72
154 81 685
37 13 779
122 120 383
53 90 148
102 178 888
133 140 48
109 48 9
148 156 996
52 132 807
119 169 425
160 119 326
67 88 909
128 1 131
164 37 456
172 39 526
97 169 694
94 76 761
160 4 668
65 22 787
117 186 325
28 131 401
110 153 541
178 31 ...

output:

-1
0
-1
-1
0
-1
0
0
0
0
-1
-1
0
0
-1

result:

ok 15 numbers

Test #98:

score: 0
Accepted
time: 376ms
memory: 48408kb

input:

11
148 10410
85 143 519
38 66 848
118 118 945
116 29 398
82 105 278
129 119 461
39 4 876
120 47 949
30 103 753
93 39 192
69 43 156
14 94 419
2 27 397
10 6 933
20 14 419
10 63 792
23 87 399
16 23 606
73 19 815
138 104 981
63 54 333
76 7 589
94 36 761
17 21 649
44 45 803
15 31 276
109 40 278
40 137 33...

output:

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

result:

ok 11 numbers

Test #99:

score: 0
Accepted
time: 606ms
memory: 79088kb

input:

8
449 472658
265 215 364
2 29 935
129 312 660
436 66 416
358 131 68
252 307 847
8 435 208
446 172 178
212 233 243
299 214 20
328 393 67
246 48 55
349 172 564
378 348 602
224 324 762
18 136 133
212 260 498
162 184 156
182 360 731
20 58 75
370 413 280
407 259 17
243 36 649
329 38 432
263 91 595
20 370...

output:

0
-1
0
-1
0
0
-1
-1

result:

ok 8 numbers

Test #100:

score: 0
Accepted
time: 519ms
memory: 42700kb

input:

13
40 12
13 1 897
28 2 590
28 17 453
14 23 819
10 30 238
2 1 863
37 33 997
6 39 853
30 3 869
36 38 315
21 3 201
10 22 707
724 7055
267 219 559
98 612 480
66 418 421
291 105 949
476 235 818
535 349 968
271 421 105
427 412 266
237 649 332
269 501 674
449 624 835
4 1 540
72 515 765
338 303 288
556 636 ...

output:

-1
1
0
-1
0
0
-1
-1
-1
-1
0
-1
-1

result:

ok 13 numbers

Test #101:

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

input:

18
357 14834
220 302 510
5 74 481
103 184 581
320 1 635
235 137 724
131 93 803
69 84 691
283 133 836
72 151 620
18 266 262
348 103 273
253 173 401
132 335 994
268 194 176
251 299 393
85 133 18
52 207 137
131 33 717
99 237 396
280 290 275
199 299 500
75 41 554
240 7 844
264 333 854
327 286 111
312 19...

output:

0
0
-1
0
0
0
-1
-1
0
-1
-1
-1
0
-1
-1
0
-1
0

result:

ok 18 numbers

Test #102:

score: 0
Accepted
time: 635ms
memory: 90896kb

input:

10
7 19
7 3 181
3 7 440
1 5 662
3 7 586
5 4 138
2 1 41
5 5 872
3 2 812
6 7 649
6 3 193
7 4 951
7 6 822
1 5 468
3 6 880
4 6 699
3 1 620
3 1 875
6 5 315
4 6 338
4616 154024
1764 4265 941
4195 500 302
481 3485 927
1287 3802 84
3287 2039 236
1450 1132 542
1843 733 504
1735 2520 783
790 4318 941
2898 338...

output:

-1
0
-1
-1
-1
-1
0
-1
-1
-1

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed