QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551669#9245. Bracket Sequenceucup-team359#AC ✓1035ms103528kbC++174.3kb2024-09-07 17:42:002024-09-07 17:42:00

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 20
(()()
1 1 2 1
1 1 3 1
1 1 4 1
1 1 5 1
1 2 3 1
1 2 4 1
1 2 5 1
1 3 4 1
1 3 5 1
1 4 5 1
2 1 3 1
2 1 4 1
2 1 5 1
2 2 3 1
2 2 4 1
2 2 5 1
2 3 5 1
2 4 5 1
1 1 5 2
2 1 5 2

output:

0
2
2
5
1
1
3
0
1
1
3
6
16
1
2
7
2
1
2
3

result:

ok 20 lines

Test #2:

score: 0
Accepted
time: 1023ms
memory: 101512kb

input:

100000 1000000
)())))))())()()()(())))()())))()))))())))))()(()()))()()))((()()))()))((())(())())()(()))))()))(()()()()()(())(()((()))()((()(()))()))()))()()))(())))()()(()(()())())((()((()((())()(()()))())(())())())))))))((())(((()(())())))(()(((())())))(((((((((()))()())())(()))(())()()()()((()())...

output:

807252937
333653009
306141773
122104482
597950507
715981381
182568448
487609661
392529556
736028324
426329153
66499770
315566541
444655931
76394527
216715407
398566026
988659878
2314391
302716489
498728925
1522883
142406094
78253278
415123885
851121113
605305965
166689862
340780822
88059318
71955647...

result:

ok 1000000 lines

Test #3:

score: 0
Accepted
time: 1035ms
memory: 102604kb

input:

100000 999999
)())()(()(()((()()((()))(()(()))()()(()()()))(())((())((((((()(()())()()())))())(()))(()()))())()))))()))(()(()))())))()))()()(())())(((((()(()()()))()(()))))))))()()))))((((()(((()))()(()))()))())(()())()((()((())()(()))()()))))((()))()()))(())))(()(((()))()(())((()))((((()()))(((()()...

output:

402892502
214899834
938727581
781653349
160260859
758544879
262745296
720834204
42963048
271586310
748943367
986678723
639328165
134613336
159371260
82874562
394258522
394494705
375828102
322739707
424538145
872892447
823697884
421610557
435534073
183003865
89151
404251848
929670889
472715017
540589...

result:

ok 999999 lines

Test #4:

score: 0
Accepted
time: 1011ms
memory: 102124kb

input:

100000 999998
())))))())((())(()()())()()((())))))))))()()((()()((()(()))((()(((()))(()))())())())(((()()))((()(()(((((()()((()))))())(())()(((()())))())((((((()((()()()())()())((()))()(()()(((())())()((())()())((())())())(((())(()(()()(((((())(()()()(()(()()(((()))()))()(())()((())()))(()))((((()((...

output:

589229850
378806717
17189272
513276973
388903354
15573206
337379415
614933739
77226868
105381650
334474125
708194095
799793957
996966343
193875984
993256553
385654388
962841214
401988000
545654424
861430641
627803113
970629869
733668058
669372341
833738960
712133526
521177172
620897050
954053422
589...

result:

ok 999998 lines

Test #5:

score: 0
Accepted
time: 1022ms
memory: 103464kb

input:

100000 999997
())()()(())(((())()))(()((()(()(((())()()))((())(((()((()((()))())))())((((()()))(())()()()(())())())())((()))(()()((())())(()()(()((()))(()()))((())((())(()(())()())(()()))))(()(()()()()()((((())))())())))())))())))()(()))(())())(((())()((()))()()))((()((())((()((()))(()(((()(())(((()...

output:

972103869
52815583
36975538
942807277
779268350
977998879
149474048
840689805
503320767
512029745
505343452
941598898
273344794
105844826
332335082
414924128
145736306
983675151
89768735
596025627
391441398
288920154
960536974
575695663
191946534
580871002
603188776
186595863
165215181
790746245
241...

result:

ok 999997 lines

Test #6:

score: 0
Accepted
time: 1029ms
memory: 103528kb

input:

100000 999996
(((())((())(())()()()()))))()()()(()))(((((())))((())(()()))((()(((())(()()(()(((((()()))))()((()(())((()((((())(())()())))(()()(()(())((())(((()()((((()()()(())((())()))())()()))())())(()())())))())((((()))(()(((((()))(())()()()(()()()(()()(((((()((()((())))()()((()))()()()))()))(()((...

output:

317161983
595949056
93798841
524173880
601024390
669989639
154565155
575792568
818268157
136111605
991333266
847150012
378409369
986282953
421020590
850559979
52073347
114271781
604334659
640229118
422909999
338488062
188413609
249844111
508809849
841591327
736530361
633843714
910519360
93611125
438...

result:

ok 999996 lines

Test #7:

score: 0
Accepted
time: 1029ms
memory: 102628kb

input:

100000 999995
((()(()()(())(()(())(()(()()))))(()))(()(()(()()()))((())(()))))(()(()))(()((()(()((()))(())))))(((((()))())(()(())(()(()()())()(()(()(())(((())(())(((()()()((((())(()()(((()(()()()()()((())))(((((())()))))(()))((()))(())(()))())(()((()(()()(()())))())()()))(()(()((())((((((())(((()(()...

output:

522986251
569857522
274182299
513438758
717505764
421686834
53987076
568056194
895421903
409740607
384742578
547379600
917225346
226046183
540069158
693176898
872736218
480008750
784434959
565264237
108353532
240021450
192461252
913279468
858826389
644800105
686176588
679893374
125293854
880296601
9...

result:

ok 999995 lines

Test #8:

score: 0
Accepted
time: 1003ms
memory: 101952kb

input:

100000 999994
((()()(()(())()((()())())))())()))((())())())(()(())))((())))(()))(())()))()()(()))()))((())((()()(()((((((())()((())()((()())(()))))(())())()())((()()(()((()(()(()()(()(((((())))(((())))(((()())((()((()))())))((((()((()(())((()))(())())))))))()()()(((((((())(())((())(()()())))(((())((...

output:

709462644
396817881
137835135
786481501
482648338
170987524
456365562
712191537
239164779
389178600
734780032
479377227
165090710
41756916
321221179
771215898
926413608
569103977
524522976
97615191
405047326
38121098
859499980
26981688
80728061
577378887
433625701
216351140
717326221
733535172
99004...

result:

ok 999994 lines

Test #9:

score: 0
Accepted
time: 992ms
memory: 102424kb

input:

100000 999993
()))))((((()))()())()))(()()()()())((()(())))())(())())()(()()))(())()()))()(()()))(())(())())()((((()))(()))((((((()()())(()()())))))((()((())()((((()((()(()(()(())(())))())())))(())())())()()))()()))(((((()())()))()())))()(()())(()(())(()()))))((()()()()())()))((())(())(((((())(())()...

output:

303668929
974632172
451994144
610836867
1984949
719122494
255048439
74974220
628335345
272652880
197468757
742800871
694990784
172726383
699008774
503390330
124089042
998148518
162322523
590959972
980070839
598551221
314696442
127173156
143487394
261157404
855529500
692017893
858244732
690083743
896...

result:

ok 999993 lines

Test #10:

score: 0
Accepted
time: 848ms
memory: 92592kb

input:

80000 1000000
((())()))))))())()))))(((()))())(())())(()(()))()((()))()())))()))((((((()())(((())))(((()(())))()())))))))(()()((()(()()))())))))())())(())))(())((()(()))(()((((())((()(()))))(()))()))(()()))(()(()()()))))))()(((()()(()))))())))(())())()()))()()()))((()()((((((((((())()()()()()((())()...

output:

242158424
769842958
166231335
414175913
60222069
71454069
794731041
236021415
574889590
930558392
62517841
914733810
730716408
393954443
557161598
926048299
104871994
315664325
620578684
107913720
168165664
492092460
748240258
399366923
14509070
254712527
343615757
287284529
445684682
867199538
2381...

result:

ok 1000000 lines

Test #11:

score: 0
Accepted
time: 876ms
memory: 92832kb

input:

80000 999999
()()()((())))(()()()()()((())())))(())))()()(())())(())()))((())((((()((((()((())()))(()(((()))()))))()()())))(()()()))()((((())())(((())(())))((((())()())))()((()))(((()))(()))(()(()(((()))())((((((())())))()()((()))()())(((((()(())()())(((((()(((()())(()())()(()()((((())(()())()))))))...

output:

88923853
385096733
662143582
819894249
451073552
983649758
244046844
730334262
865952018
680003393
96837936
268466573
156372357
396598440
466557930
493985169
414061112
112940857
778042483
29187063
590044837
924190539
977340920
243895972
934200816
721169551
213927757
488522990
828944132
138669579
830...

result:

ok 999999 lines

Test #12:

score: 0
Accepted
time: 859ms
memory: 92620kb

input:

80000 999998
()(()()((()())((()((()(()))()()(()(((((()()())))(()()))()(()))())))()))()(()()))(())(()(()(()()()())((()((((()()))))()()()(((())())(()()()(()(()(())()()(()()()()())((()())(()(()(()()()(())(()(()((((()(((()(()(((((((((((((()()))()(())((()(((())))))))()())(())(((()(()(()())(()(()))()())()...

output:

38218570
142309639
223333620
417179594
707107546
445214235
859777455
156299343
409734786
520071865
16939171
878995903
612338202
204757897
589666236
964340636
780163007
537685182
96100921
24799274
929271438
526867242
365908063
477991147
862718929
794499060
533363805
554006248
629604264
645875233
7842...

result:

ok 999998 lines

Test #13:

score: 0
Accepted
time: 876ms
memory: 92828kb

input:

80000 999997
(((()))()((())))))(())))()()(()()()(()(()((())()(((()())()))(()))(()()()(()))(()(()))))(()()()(()))))()(((()(()()))((())())((()))()((((()()))()))))(())())(()()()(()()))(((((((())()())((()())(()()))((((()()()))((((()))))))((()((())(())(()))))))((())((())(())))()(()())()((()(()((()()(())(...

output:

28377171
427775956
24130295
68193145
742833230
225727222
646889739
82039456
487507470
789942643
356592513
786270620
403047505
997509337
943240016
972942972
540328021
416806996
509576299
934719563
720010201
286429562
565995753
26909049
696336947
458465377
467540778
93739018
490963206
536139604
643900...

result:

ok 999997 lines

Test #14:

score: 0
Accepted
time: 879ms
memory: 92868kb

input:

80000 999996
(()()((((((()((()(()((())))(()))(((((())()))((()()(((()))(()()()()))))))))()))))))((())))(())()))))(((())()()))))())())))()((()()()()()))((())((()())))()()())((())()()(()(())))())(((()((()()))))))))()()())(()(()()(((()))(()(()()))((((((())))(()())))((())))(()())()()(()()((((()))())())((...

output:

686242650
891003449
378893279
709771493
567723040
10652832
90367287
796185368
901832677
372097881
933094678
519292858
142323419
643786964
989599895
977576408
885379735
92630918
314230829
552560910
253625040
560141368
573866015
230300191
460241092
313426415
852045144
443870846
477274583
29650470
3556...

result:

ok 999996 lines

Test #15:

score: 0
Accepted
time: 881ms
memory: 94852kb

input:

80000 999995
(())())(((()()))((((((((()))()())())())())())())(((()())())))())))()()()))())(()()(()))())((()()(()()))()(()((()(()())(()())))(()())))))())()())())((()()))())(())(()(()())))())(()(()))((())()(((()))(())))())((((())(())(())((())))(((()()(((())(((((()()))))()(((())(()(()((()()))))())((()(...

output:

138481795
704868144
51675996
765731428
925578706
123957081
667160555
274707415
656451455
492091860
321894004
762289465
5788363
598870180
732409607
437361746
491450171
620340444
614663780
512063470
993921865
416922367
515680182
179426373
5314167
672651799
286975919
488780276
924956593
1016092
6791024...

result:

ok 999995 lines

Test #16:

score: 0
Accepted
time: 875ms
memory: 92500kb

input:

80000 999994
()()(((())))((()(()))()))((())()()())()((()((())()()())()(()(()((())))((())())))()((())()))((())())(()())()(((((())()(((()))))(()(())()()(())((()))((()()(((()(())((()))(())()()())((((()))(((((((()(()))(((()(()()()))))(((())()()))(()(())))((())))(((()(()()))()()(()()))(())(((()(()()()(((...

output:

6533743
989330207
241331094
819548997
17522465
821617709
25848383
59919114
13405516
281796939
960664573
470182299
139485073
537588770
829549661
550666309
784962419
390188790
234639988
268111827
874720826
152655343
977363189
687878975
492289023
511342702
781431769
925267731
343335369
629914768
898184...

result:

ok 999994 lines

Test #17:

score: 0
Accepted
time: 878ms
memory: 94804kb

input:

80000 999993
()(()(()))))())((()))((((()))((())())(()((((()()())))))()))(()(()))(())())(()((()))())))(())))()())()))(()))))()(())(()((())))()()()()((())()))(()())((((()(()((())((()((((((((()))(((()))()))))))))(()())))()))((((()(((()()()())(())())))))())(()()))())()())((()(((((()))()())()))())()))(((...

output:

800970710
505182329
29346401
112557992
868132180
792292011
983045434
744617930
359123358
610050421
932162581
535655226
903936665
986865248
829418062
613041729
128943395
47905663
88336118
172522243
413625758
282695633
705813695
740726617
292943226
881811618
948573520
320179160
860397991
233443673
513...

result:

ok 999993 lines

Test #18:

score: 0
Accepted
time: 713ms
memory: 80440kb

input:

60000 1000000
())))(())()))))()))))))((((()()()(())())((())((()((()()))(()))()))))))(((()(()(()(()()((()(())))((())((((()((()()())(())()(()())()()(())(()())()((()())()(())(()(()(()()()))()))(((()(((())(((()()()(()))()))(())))()((())(())(((()(()((()(((()((())()((((()()))((()(((()(())(((())))((()))))(...

output:

355025021
953307950
95424051
321294307
888255421
701486250
227697299
797029900
752912937
470346553
846331579
940146170
359816389
484866444
816152996
951762198
422166103
471959360
897070803
989945972
431258497
911211692
328340563
337358064
403824113
766879572
505023892
991640066
5414936
823172974
850...

result:

ok 1000000 lines

Test #19:

score: 0
Accepted
time: 723ms
memory: 80412kb

input:

60000 999999
)())((()))(()((((()()()()(()()(())))))))))(()))(()(()())())()(()(()((()()((()))(()(()))()()(()()()))(())((())((((((()(()())()()())))())(()))(()()))())()))))()))(()(()))())))()))()()(())())(((((()(()()()))()(()))))))))()()))))((((()(((()))()(()))()))())(()())()((()((())()(()))()()))))(((...

output:

570283995
877785621
721974460
373295838
689241408
494831334
522315782
838570583
899462239
197224108
185385108
267204854
442686416
706046568
486444565
757373429
67742641
859254178
97046842
261817498
329049068
276398094
863472259
566435058
679460179
212048864
499459405
25337123
586897601
478612252
304...

result:

ok 999999 lines

Test #20:

score: 0
Accepted
time: 733ms
memory: 80812kb

input:

60000 999998
)())())))))())))(())(())(()(((((((())()((()(()((((()(()()(((()))()()(((((()()(((((()())()))()())()))(((()()())))()()()))())())(()(()(()))(((((()((()()()))))(()))((()()((())())()()()()((()())))()())()(()((()((()())((((())()())))())))))())(())))(()))()((()(())())()((())(((())(((()(())(()(...

output:

996394133
489926235
523318773
19701772
319155291
535965250
814949764
868568912
454517007
232744048
162922656
334459955
737735334
788881453
14834141
899723388
523950304
380664969
172075884
139183857
39771269
158806569
267232849
244423672
491356597
123766461
947799257
610565049
750601553
236423679
561...

result:

ok 999998 lines

Test #21:

score: 0
Accepted
time: 705ms
memory: 80280kb

input:

60000 999997
)((()())())))((()))(()(()(()((()(()))(((((())(((())))))(())()(()))())((()()()))()(()))))())))))()()))(())())()))()((())()()())())(())()))))(()))(((())(()(()(((())))))(())(((()()))())()((((()())(())())(()))())))))(())))()))(((()))))))))))()())()((()))()((()()))()(((())(())()))(()((((((()...

output:

343818130
791287084
160957103
263150051
862732458
682850203
411374111
652082767
929084402
620236206
787077686
992889239
907486883
80786965
74845078
876338573
378539791
246771125
833884812
47824633
837515865
319722508
636899468
94577181
707738818
676504794
294762812
609260590
9209443
135018120
229704...

result:

ok 999997 lines

Test #22:

score: 0
Accepted
time: 722ms
memory: 80788kb

input:

60000 999996
))(()(()()))(()))))))))((()()())))(())()))))(()((())())))(()()))(())(())((())((()())()()(())(((()))(())()((()(((((())((()())))()(((())((()()(((()()()))())))((((()))()))))(())(())(()()(((())()(())))()())())(()()()((((()()(()(((())()))())())()(((()((())(((((((()))()((()((()))((()())(()())...

output:

944583689
191858266
104645441
494825628
225017100
466666333
473995372
400320533
536446750
985659258
992452462
161022952
264588504
826680881
754513989
303080715
753224743
897655188
762490499
523161412
876995669
762849001
549797526
343981519
352625685
948447437
245812407
739489907
190501964
991521072
...

result:

ok 999996 lines

Test #23:

score: 0
Accepted
time: 705ms
memory: 80536kb

input:

60000 999995
))((())))(()()(()))))))))))))()(())((()(()()(()((())()))()))()(())(()(()())))))((())))((()(()))()))())()(())))()))(()(((()))))()(((()(())()((())(())())((())()((()())()()()()(()(((()(()(()((()(()))()))))(()())()))())))()()((())())(((()))((()(()))(((((()()(()()))))((())(())())))))))((((()...

output:

236435057
238288870
344769979
237634425
179725009
84494536
50741735
495033060
180221093
663543703
441840805
764851604
308854226
316254197
226035242
580258131
434094013
304394927
344185570
493031167
270680931
242001477
253235181
214869960
587055600
775186744
430913863
772429557
138565618
976694269
35...

result:

ok 999995 lines

Test #24:

score: 0
Accepted
time: 712ms
memory: 80348kb

input:

60000 999994
)())((())((((())()((()((()(()))()))(())()()()))(())))()))(())(((())((())))))(((()())(((()((((((()()(())(((((())())()))))((()()((()((()()()()()()(((()))(()()))(())))))(())))()))()(())(((()())())(()())()())))(())())))((()(())()()())(((())((()())()()()(((((())())(((((())(((()))()()(((()())...

output:

645485721
889226298
994624067
207798731
995747083
288838471
932090697
776848617
114307403
326029708
403511050
704045947
594576219
639533604
600122059
767669294
891395049
777694068
710475917
194993009
464942024
932836507
781548079
413375593
692547203
372647576
481347067
616353
132824353
691844396
535...

result:

ok 999994 lines

Test #25:

score: 0
Accepted
time: 703ms
memory: 80748kb

input:

60000 999993
)())))()(()(()((((()(())))))())(((((((()((((()(((((((()())))())()((()(((()()())()(())(())(()()))())())())(()(()))(()())))(()()(())(((()((((((()()())()(((()())(((()(()()))))(())()(()())((()())())()(())((())))(()))))(((((())((())())((()(())()))()))))(())()(((((()(()((())()(()())(((((()(()...

output:

231292099
771892982
588218495
7487080
319869391
266100362
146313822
273461657
432221486
898305687
680062005
318663475
237118313
301120028
391629719
614046196
669051701
520452455
149173202
258715907
834095984
597096445
538018682
35830239
613774579
44612168
924392428
686793911
399727013
669627209
8284...

result:

ok 999993 lines

Test #26:

score: 0
Accepted
time: 584ms
memory: 65848kb

input:

40000 1000000
(()(()())(()(((())(()()()()())))())(()(((()))())(((((())))()()()(((())(())))()()()()))())()(()))(((())((((((()()))(()))))(((()(()())((()))())()((()(())()(())))()(())((())((()()(((((()()()))()(((())())(())))()))())())((()())())((())))())(()()()(())(())))))()(((()(()(())()))())(((())()((...

output:

123520759
633627186
11352476
870959481
781188247
911329282
650687069
367758195
42570171
305752633
425026203
609800561
84854693
309943806
489328464
463050269
617602625
809963716
520709886
251143792
876747884
720763839
40379079
15464171
254098363
76380199
661835694
234882517
884986455
208648888
0
6802...

result:

ok 1000000 lines

Test #27:

score: 0
Accepted
time: 548ms
memory: 66192kb

input:

40000 999999
((((()())(())()))(((()()()()()))(()((())()(()))))())()))(()))()))))))))((())))((()((((((((())()(((()((()))))())))()()()(())(()(((((()(())()((()(()()(()))())))))((()()(()((()(()((())))())))))()((())))(()(())()))((()(()(()(())((((()))(())))()((()(())()())()())(()()()(()()()))()()))(())())...

output:

681629849
38188035
16627600
606391623
367818870
462342400
697853972
33771994
706328418
940527520
891128696
353268445
818723064
25376164
586325911
767559591
969784672
893007945
797667669
66035845
58927003
828275402
802655608
741821160
32496112
257136428
59386114
12306670
52538820
371082043
925231291
...

result:

ok 999999 lines

Test #28:

score: 0
Accepted
time: 562ms
memory: 67980kb

input:

40000 999998
))))()))((()))((((()))(())))()())(((())()))(((())()()))()))(()()((()()(()()))))()))()(()))((()()()())()())(()()())))(()()())()(((((())(())()()(())(()(())()))(()()(((()())))()()((())(()))(((()())))))))()))())((()()(()()()))()()()())(()))))(())((()())((()))))))((()))())))))())(((()(()((((...

output:

110521915
151117508
671898241
624307432
12243368
661706383
748308044
416957985
244385843
91572681
699960833
671576686
139706964
437349336
398020609
261651013
38192979
447822595
117189002
730220591
80525214
582123327
84740382
519699169
381116426
619088415
167971470
550775914
330013892
803805536
57260...

result:

ok 999998 lines

Test #29:

score: 0
Accepted
time: 549ms
memory: 65896kb

input:

40000 999997
)))))())(())(())((())())()(())()()))((((((()((()))(((()((((((()))))))))(((((((())))()(()))(()())(((()(()()()((())))(()())(()()((((()))()(((((())())))(((()())(())))()())))))(()())())))()(())((()(())))()(()(((()((()())))))()))))))(()()(())((())))(((((())))))()(())(()(()))(())()(()()((())(...

output:

984671131
2179286
861909683
768972034
266831652
686288501
888988576
46873294
143415113
512172840
813465898
579582391
594994622
846433811
705411412
198581701
9045696
51844874
153422603
957209064
623418943
435032209
56005685
741237527
552079247
860903041
379468324
299801479
776267811
96053805
72487038...

result:

ok 999997 lines

Test #30:

score: 0
Accepted
time: 565ms
memory: 68052kb

input:

40000 999996
)())))())))((((()((((((()()))((())))))()(()))()))((()()()))()(()()((()())()(()))()(((((()(()))()((((())(())(()(()())))()()()()()))())())))))((((()(((((((()))(()()(())(()(((())())()))())())()))((()(()))()((()))()()((((()())())()))()))(((()))(()())(()((()()(((((())()(())))(())(())()(())((...

output:

605039528
19322951
613455982
817733448
968102288
335301588
672478744
579204911
606647803
834623655
851473428
641735170
880164927
53917593
338924630
472709427
888111210
793213421
405783113
476083537
452677602
554814940
947301818
18105285
203245207
735684255
970007929
66665938
778672408
539040900
2704...

result:

ok 999996 lines

Test #31:

score: 0
Accepted
time: 565ms
memory: 65988kb

input:

40000 999995
)((((()))))(()))))()(((((()((((()(())((())((()))))(((())((((())()()()))))))(((()))(()(((()))((()))(())()))())()))))()())()()((()))))())(()()()))))())))(()))))()()(((((())(()(())())(()()()())()))))((((()((((()((((())))(((((()()(())))))((()))((())()())())))))()()()))())))(())()()()(((())(...

output:

152190361
23030052
3657990
122161278
528590485
89934696
15977964
927664339
877692256
90648095
0
753945896
682814671
282551268
669587063
165370501
545529475
257072394
331145110
71379024
146072854
982205322
23407453
64659963
972970926
267837855
437504961
466157503
377822869
239670529
929903025
3063794...

result:

ok 999995 lines

Test #32:

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

input:

40000 999994
)(((()))()((((((())()()))(()((()(()))))(())(()())))(()))()))(()(()(())))()((()))))()(())(()()))()(((())()))())))())))()))(()(())))))(())(()())()())()))(((()))())())(()))))())()()))())))((((((()())()()(())())))()(()(((((()()((((())))(((((((())(()())())()(()((()(((()(()))))())((())((())((...

output:

411352290
538603263
68745267
412852315
383441464
888505150
58304637
315036530
688771140
693143835
583744904
892495082
570384659
273485452
405503356
217937054
603998865
930002021
835597016
813464563
24128632
407744122
540752246
807019115
456459744
622455552
925093780
563254539
254482714
124734705
804...

result:

ok 999994 lines

Test #33:

score: 0
Accepted
time: 566ms
memory: 65948kb

input:

40000 999993
))(())()((()))))()))))(((()(((())(()(()))(())(())()))))))(()))(((())()(())))((()(()))())(()((((()())))))(())()(((()(()(())(()()()))(((()))())()(()()())())))()(()(())))()())((()()))(((()(())()(()((()((((((()(((()(()))))))(((()))()()(()(())(())))()()))(())((((()(()))(()()()))())()((((())(...

output:

298464494
1230478
871625630
141689824
333034148
543077536
621660563
103240668
715355209
761398549
493381889
539702645
801587663
597985982
785492535
393582643
882866737
618167454
989317128
63539383
125539080
719699899
515480445
768035246
243851658
412166784
101964803
428356065
49873845
227280101
1035...

result:

ok 999993 lines

Test #34:

score: 0
Accepted
time: 402ms
memory: 53716kb

input:

20000 1000000
()()))))))((()()))(())(((())())(()(())))((((()))))((()))())(()(()(()()())))(()())()((()))(((((()()(()())(()((()((()())())())()())))))())))())()(())(()())))((())((((()()(()(()()((())(((())()))()())((())()))))()((((())()))))((()()((((()((()))))((())()()()(())(()()((((((((((())(((()((((()...

output:

180985558
775891998
338881436
387611445
475538891
637650615
350197439
148637487
925753877
319975760
810107228
490116328
303621670
975371772
384946739
423080584
994085445
219694024
853700704
740462738
614683284
952695499
56334107
196289623
67491877
680003391
555547600
328920552
602293740
99408434
475...

result:

ok 1000000 lines

Test #35:

score: 0
Accepted
time: 409ms
memory: 54032kb

input:

20000 999999
()((()()())))(())))()()()((()()))))))(())((((()()((((())()()((()))()((()))))((())())()()(())()(()(()(())()((((()((()()))((()()()(())))))))(()))()())(())))()()()()()))))()(()())(())()()()))(((()(())(())((())())())()(()))))()))())((()(((()()()(()((()))())((())))(()()))))()()(()(()((())))(...

output:

758090546
377316836
399779306
232803199
945526601
877694765
172656250
549795370
660348663
146465646
854025383
812515420
232622199
327628098
572421039
76993332
589004513
818992452
267929242
995428666
913268085
592043623
934238226
244420693
38898320
52628934
515921071
843204318
858576179
930583630
384...

result:

ok 999999 lines

Test #36:

score: 0
Accepted
time: 416ms
memory: 53788kb

input:

20000 999998
()(((())()((())(())(()))(()))()(()()())(())))((())(()()))())))))(()))()(((()())))(()))()())))()()((()(((()))))((()((((())(())(())()())))(()())(((()()(()(())()()()))))()())())))(()((()(()(()())))()))(())))))))((()()))()))((()))()(())()(())())()(()((())())()()())))()))()((((((((()(())()))...

output:

957037814
531166787
443280446
318052314
436550580
581556681
3151734
958740851
17916269
103929368
585038489
375697989
770630002
403292247
346830866
386982235
618238035
267534448
791962662
341896944
919340195
334091012
4119298
922109212
448589967
733918126
414828261
111950457
621761844
461781575
27504...

result:

ok 999998 lines

Test #37:

score: 0
Accepted
time: 415ms
memory: 55780kb

input:

20000 999997
(((()))))(((((()(())()(()((()))())(((()())()(((()()))))(()((((())((((()()())((()((()())((()(()((()(((()))))()())((((((()()())()()))((()())())()))(()((((((()((()))))(((((())((((())(((()()))()()()))()())()()((())))(((())())())()()()))(((())()())))()())()))((()()()()))(((()))())()())))))()...

output:

634729966
931769016
716123247
104184149
852144781
457297947
962215361
415615007
203563171
754738672
317565282
444659224
387578379
373750898
200483329
312358077
329866419
697807575
822424876
95889010
769946900
771432685
652061810
955193460
844774559
911857468
144192023
322023305
218950232
471887319
3...

result:

ok 999997 lines

Test #38:

score: 0
Accepted
time: 401ms
memory: 53500kb

input:

20000 999996
(()))(()((((())))()())))()))())((()(()()(()(())()())())()()((()(())()((()())())))((()))()((()()(((((()(())()(())((())))(()())()()))(()()(()())(((()(((((()()((()))()()))()()()(()))(())(())))))(((()()(((((()()())(()(()((((()()(()(())()))((()(()(()))())(((()()()))))()))(((()((((()))))())))...

output:

32864463
874805430
846421324
856825954
66101548
50238757
921291639
222963582
747568910
207316248
31792
784593515
710690103
584444480
429485364
672261291
91584452
623314619
310861415
512297957
606441625
478844343
947053051
375572190
224597050
756948449
126956046
809567498
217535452
491897386
69111956...

result:

ok 999996 lines

Test #39:

score: 0
Accepted
time: 425ms
memory: 53764kb

input:

20000 999995
()))(())(())()(()())))())))(())))((((((((((()))()))))))())(())(()((((())()((((())))(()))))()))()()(())))())(())(()(()))()()()())())(((()((()))))(()))()((())((()(()())))()())()()()((())(((((((())()((()())))(()())()()()()()))))))((()()))(())(((())())(()(())))((((()))))((()))())(()(()(()()...

output:

396634833
171780985
372069024
146579698
639319048
265502672
229013686
46724791
176963205
665014409
448973572
86778066
259621678
753539264
758567811
487186476
87148
434863553
619780968
970444608
65619828
406297319
87315950
790123394
908536728
702078662
669410010
130011372
637160448
940259008
21957713...

result:

ok 999995 lines

Test #40:

score: 0
Accepted
time: 402ms
memory: 55636kb

input:

20000 999994
()))())))))))())(())((((()()(())(()()))()))((((()(()(())(()((((()()))(()))(((()(())()))))(()(())()()()((()())(()((()(((()))()())()))))(()))()()))((((()())()()())()()((((()())))))((()((((()))()(()()(((()(()))))))())((()()((())((((()))()(()(()))(()())(()(()((((()(()))((((((((((((((()()())...

output:

404206336
611084012
752387675
338995840
698752513
112253554
917722972
245549272
319970112
192258082
510068584
306788693
600868889
155396885
717574898
524146366
920415055
202429903
573814008
206252727
394151496
396968659
253677041
731488955
405916570
589236136
170571622
945509037
431243834
453090787
...

result:

ok 999994 lines

Test #41:

score: 0
Accepted
time: 409ms
memory: 53928kb

input:

20000 999993
()(()(()))()))(((((((()))()()(((()(()())()()(((()(()(())))((())(()))(())())())((())()))((((()))))(()))))()(((((()((((()(())((())((()))))(((())((((())()()()))))))(((()))(()(((()))((()))(())()))())()))))()())()()((()))))())(()()()))))())))(()))))()()(((((())(()(())())(()()()())()))))(((((...

output:

792129938
44527136
143828678
490331776
432187138
412442304
658899951
45517972
771915705
117483658
29306839
19077514
399600724
606778360
820899704
155530653
352650510
469533239
343337146
856340379
454851134
234322450
532135944
608088395
812174906
413806333
341876169
715062501
396971697
23704594
27769...

result:

ok 999993 lines

Test #42:

score: 0
Accepted
time: 300ms
memory: 43892kb

input:

5000 1000000
()))())(((())()(())()()(())()))(())()()(())())))()()()()()(())))()((()(()()((()())))()()(()))(()))()()(())))()))()((())())(()()(()(()(()))()))(((((((()))()()(((()(()())()()(((()(()(())))((())(()))(())())())((())()))((((()))))(()))))()(((((()((((()(())((())((()))))(((())((((())()()()))))...

output:

863866147
0
986743306
448089409
415730302
103415571
583365848
360528068
580477275
116714441
51738
0
208659757
838040866
964622385
24190814
360777188
707791094
991336
248174259
981480284
200666208
549554494
716712752
553374957
23086731
593607965
991180210
435240485
863366430
110592
907574437
83469
84...

result:

ok 1000000 lines

Test #43:

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

input:

5000 999999
()()()))(((((())())()(((((()))(((((()(()((()()())())()((())))((())()((((())((()((((()()(()()(()(()(()))()))()(()(((()(()((()))()))()(()(())))((())((()()((())))(())))()(((()))()())(())(()((()()()(())((((()(()()))(()()(((((()(()()()())(((()()(((()((((()(((((()())()((()()((()))()((()((()))(...

output:

127335815
244014815
449993532
147050453
203343865
668279116
703226953
386459427
210614975
404908305
5723851
431353583
852228507
390364973
237166848
17429599
99011959
80612093
880537983
194126222
698889339
324705446
186567404
585390949
465280
764638702
901507493
447939780
556764038
872087685
50819152...

result:

ok 999999 lines

Test #44:

score: 0
Accepted
time: 272ms
memory: 45540kb

input:

5000 999998
()((((()(((())(()())(()))()(()())))(()((()))()()))))))(()(())()((()))()())((()(()(((((()(((())(())(())())))))))(()()))())()))))())()())))((()()())))))()())))))()(()((()()(()((())))()()(((()()()((()(()(())())())((())))))()))()()((((())((()))()()))(()(()()()()()))()(((()()(()())()))()))()(...

output:

732312011
375698302
2
702174723
755977378
296262404
789949096
7206600
929138428
483672674
178087249
473025910
661722381
591487505
109641761
285656379
882276675
875868601
226003899
241890560
374818595
549824397
291538363
308056358
208328224
854900057
264965776
773166009
885209882
473715024
867271569
...

result:

ok 999998 lines

Test #45:

score: 0
Accepted
time: 282ms
memory: 43936kb

input:

5000 999997
(()((())))(()()))()(()))(())(())())((()())(()))))(((()()()))()))))()((()((()(()()()()(()()(((()()(((())()((((())()()())))))()))()(())))(()))))()())())()((())()()()(()(()))(())()(()(()()())(((()))))(((())(()()())()(((()))()()))(((((()()))()((()((((()()((((())))()()(()((())))(())()())())((...

output:

463035278
607637104
860407258
339150764
261963770
551594368
405890549
598859953
559240225
43140826
887360318
712075276
801040524
246108557
200008145
912691606
695652868
75285632
104947
795191748
907222780
625377588
2419835
36973455
392864599
996583465
872532365
140546250
397937580
89575842
88695448
...

result:

ok 999997 lines

Test #46:

score: 0
Accepted
time: 293ms
memory: 43448kb

input:

5000 999996
(()())()))))))())())))(())())()())((()))(()((()))((()(()((())(()())))()))())()(((())(((()(()()()))()))()(())))((((((((((())(())((((()((((((()()())()()))((()(()((((()()()()((()()(()()())()())))((()()())(()()))))(()())))()))))((((()()()))))(()())()))()))((()((())()((()(((()()))))((())))(()...

output:

156410336
178454378
201177511
693216538
548307960
95018
155087803
855074502
55949211
596036530
396434546
637062879
565945557
493196728
681810004
895764280
537959879
378003570
559946848
681708788
285651421
832979899
46732773
250423973
240
206191469
561465251
669597327
801346658
896591039
248226006
39...

result:

ok 999996 lines

Test #47:

score: 0
Accepted
time: 287ms
memory: 45568kb

input:

5000 999995
(()))(()())))))((()())))())()()((()((((()(())(()))((((())))(())))((()())(()))()((()))((()()))(()))()())((((())()))()(((()()(()))(((())())()()(()()(())))))))(()))((()()))(()))()))()())()(((()((()()()(()())((()(()()()()(((((()()))()))(())()()))(()())))((()))((()((()(((((())))(()()())))()()...

output:

476338640
59355421
50759977
799217941
260681442
384635798
936968209
540596548
881486283
500734475
423448545
498286178
907802592
229584341
180283383
32978
734524275
814489363
877634970
798632389
225687438
187270489
20242997
787952917
970748066
438941126
418631380
103473118
525835812
48306937
70297204...

result:

ok 999995 lines

Test #48:

score: 0
Accepted
time: 290ms
memory: 43484kb

input:

5000 999994
()()()))()()((()())(())())())))()(()))(())))))())(((((((((((((())))((((()(()))()))()((())))(()))((()))())(()(())))(()))()()((())(()(((((()()))))(())(()))(((()()))))()(())())(()((()((())(())((())))()))))(((()()(()()()(()()()))()))())()))(())()()))()()))(()()()))(()(()(((((())))(())))(((()...

output:

248294069
787192362
489378052
127631586
865849681
814325916
516178610
952379878
872258662
536050437
177616
776023689
253950095
375830809
237153500
71694556
92016943
267714348
359549086
460638958
850091940
35588645
598344332
96776371
3311019
364372064
105139
623151716
69170283
138889947
619185315
0
6...

result:

ok 999994 lines

Test #49:

score: 0
Accepted
time: 258ms
memory: 45348kb

input:

5000 999993
()()((())(((())())))((()())(()))((()))))()((())))()())(()))())))(((()()(())()())))()(())(()()(()()()())()()(())()()))))(()(((()))))(())((((()((()((((((())((()()()()(()()()(())((())())()()((())(()))()(()))((((((()())())((((())(())()())()())((()()((((()(())))(()())((()((()())(())()()))()((...

output:

103730368
11833833
0
211275197
870346863
439755757
833895925
793543890
844902637
831010439
108843452
655334727
750515671
806198301
517373799
641421476
374797751
57116871
888218395
950524370
520631449
599402869
394033463
449714437
24732992
926494500
708964126
120597
996710964
640525472
559163818
2852...

result:

ok 999993 lines

Test #50:

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

input:

500 1000000
())()()))())))())()()()((())(())())()))((((())()(((()(()())(((()))((())())))(()((())))))()))))(())(()())))()))(()))))(())))))((()()))(()(())(()))()(()(((()))(()()(())()()())(((()))))()))()()()(()()))))(()())((())()()())(())()(())))())((())(()()))((((()))((()()))()()()(())())()))))()((()(...

output:

0
503164092
0
929070134
282584425
594549
0
260592003
0
532920449
0
175076785
4809
141647500
472357802
0
994092277
52148717
351698236
97492092
0
75421812
974279727
796465423
3025302
433702300
17615029
62008900
0
6392681
0
275157091
2668
0
345135896
15021636
0
0
2183927
379903562
622249024
0
35435004
...

result:

ok 1000000 lines

Test #51:

score: 0
Accepted
time: 253ms
memory: 41168kb

input:

500 999999
()())())((()())))(((()((()(())()())()))()((()()())((()(()(()()))(())))()((((((()())((()(()(((()((((())(()(((()))()))))((())))((())((())))))(()()))((())))()())((())()())))((()))((()))())(())))))(((()(())))(()))(((()(((())(()((()()(()(((((()())))()()()))(()((())))()((()))))(())))())()))()((...

output:

567395003
50951326
9732
242384692
0
970755462
187513425
29406360
17280
99721502
168427441
489888550
250906035
808680865
65790075
0
797022130
7694775
538369191
0
0
101141452
0
0
299
512694279
0
697734202
644245478
1368032
671135595
470581496
116214762
28451107
0
704684271
711141090
0
0
616593685
0
84...

result:

ok 999999 lines

Test #52:

score: 0
Accepted
time: 238ms
memory: 41304kb

input:

500 999998
(((())))()()(((()(((()()))))))(()))()())())(()(()))())((())))()))())())()()(()))))())())((()()()()((())))(())()((()()))(()))))()))(()()(()()())(()))())))))()())((()()())()))(()()())()()(((((())))((((()(((()(((()((())))())(((())())()()(((()(())()(()()((())))(()(()(()))))())((()))((((()))((...

output:

0
853352928
474064366
0
44999610
205240114
664810966
0
783785016
290460338
879605178
0
929169853
316532712
349837298
55318437
829201542
743292093
0
818079199
733691398
300259806
722801959
930249122
46685619
789800316
44
480868684
690601115
573233378
684572315
208789391
36669998
208982055
515210835
0...

result:

ok 999998 lines

Test #53:

score: 0
Accepted
time: 244ms
memory: 41284kb

input:

500 999997
((((((())))(())(((())))((((((((((((())(())()()(()())()())(((()((()(())(((())((()()())()))(())())(((())(((()())()(())(()))())))()()(()))((()(((()))(())())((()()))(()()(())))))(()(()))())()))()((()((())())(())()((()(((())(()())(()))()((()()()((())))))(()(((()()))()(()())))(((())(((((())()))...

output:

129103197
306301931
0
847170979
722027960
440895174
117908774
30336680
562416852
722264056
239634723
0
652528415
140
0
124352
420943777
311966786
0
337964961
211038004
47715120
958611313
130188791
0
649066348
2017
3931524
7503489
494919392
506322736
0
0
0
21810
0
762756020
573627630
898954061
932655...

result:

ok 999997 lines

Test #54:

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

input:

500 999996
(()(())))))())()()((()())((((((((()()((((()))))())))((()())((()((()(())()(()()))()))(()())((()()((((()))((()()((())(((())())))((()())(()))((()))))()((())))()())(()))())))(((()()(())()())))()(())(()()(()()()())()()(())()()))))(()(((()))))(())((((()((()((((((())((()()()()(()()()(())((())())...

output:

99024
385117599
14007939
13992
0
351574496
0
0
702988936
48097802
760920682
763047422
73780530
253665452
0
522589870
243279163
896359019
498757078
877234287
538386594
0
944985817
688828267
0
738654569
0
117
1529
818480378
116884038
419576385
682433499
703462248
0
965782468
702286278
0
16402248
70051...

result:

ok 999996 lines

Test #55:

score: 0
Accepted
time: 251ms
memory: 41240kb

input:

500 999995
()))(())()(()()())()(())(())(()))(()()))((()(()()))))((()((())(()((())()))))(((()()))((((((()())))()))(((()((()()())))()()))()((((()()((((()()((())()(()(()())))((()))())(((())())())(()))(())()))(())))(())(())(((()))(((()()()()))(((()))))()())))()((((()()()()())))(()))()))((())))))(())(())...

output:

196437181
711719962
0
914289704
0
10855716
689704506
170690138
975019888
232049059
702479795
146067320
588580913
147276331
0
5056273
679701898
136957629
0
369753122
9597
3695040
642123259
0
2995
406486598
838613190
0
0
92007391
8215641
676932591
258504299
332740711
366403409
0
293890155
53524862
237...

result:

ok 999995 lines

Test #56:

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

input:

500 999994
()))))()((()))()))(()()()((())))()))())()))((((()(()(((()))(())(()))()))()))())()())()()(())))())()))))))()))))))()))))(()((()(()())()(()))()()))))))())()()()))))((()(()))()(()())))))())))(()((()))))()((((((()()(()(())()(())((((()(()()))))()))((((())(((((())))())(()))()())()())((((()()(((...

output:

133349306
400670814
0
656178924
843261935
841970373
583418313
243395068
0
228381536
466169904
7
309690685
1685
406773337
433276934
0
590537141
838665146
295761890
98640799
0
18796631
684163685
20951682
464995950
544201780
469962380
11372
298645874
10415547
882591569
402207735
246223015
0
657751
1120...

result:

ok 999994 lines

Test #57:

score: 0
Accepted
time: 257ms
memory: 41228kb

input:

500 999993
((())))))(())()())(()(()())))))())))((((()(())(())()))(((((((((()(()))))))()((((((()))()()))(((())))(((()((((((()))()((()(((())))())(()))(()))(()((((())()))()))())((())))))))()(()))(())))))(((()))(())))()(()(((((()))())))(()))((()()))))(())((()))))())(()(())))((()()()()))((())(((())((((((...

output:

212953715
180413908
213608708
545941476
820810037
52688530
46001526
975337787
2096
20958
525567885
149208815
733700381
0
773986823
599174852
4181765
0
778688047
0
364581011
425076646
681882034
792601590
74259235
277135264
53
465633373
787966130
592071489
0
499433684
824248091
681882539
485209587
0
7...

result:

ok 999993 lines

Test #58:

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

input:

100 1000000
))()(((()((()(((())))())))))))())((())((((()(()()()())()))()((()(())))(())((())()()())())((()()))(()
1 53 96 4
2 10 33 4
1 83 97 12
1 28 89 12
2 7 85 5
2 54 63 16
1 9 97 8
2 12 28 7
1 46 66 16
2 67 68 4
1 9 47 17
1 44 86 6
1 21 27 14
1 56 94 20
2 14 61 16
1 61 92 17
1 85 92 9
2 89 92 4
2...

output:

789698
2304
0
744518346
505236994
0
416966274
0
0
0
0
10103852
0
0
0
0
0
0
406033108
273092200
7272
46808925
0
12026
0
292227696
0
8221020
0
0
0
0
0
0
0
411517657
91335681
0
0
181
0
7535507
0
9705034
27099601
0
6
0
355155776
0
0
0
95712
847014989
0
514959852
1486
753318
0
1659274
474
38180
101
15177...

result:

ok 1000000 lines

Test #59:

score: 0
Accepted
time: 229ms
memory: 41124kb

input:

100 999999
)((())()))((())((((()(((())((()())()((())))()((())(((((()()()(()()(()(((((()())()(())(())(((((((()))
1 24 55 4
2 77 90 20
1 49 58 12
1 33 91 19
2 50 53 3
1 8 21 18
2 11 57 10
2 23 34 1
2 83 86 13
2 21 53 13
1 23 34 19
1 29 97 8
2 62 70 11
1 45 86 6
2 40 69 11
2 14 40 17
2 66 76 16
1 45 66...

output:

21360
0
0
0
0
0
1244160
321
0
0
0
73210402
0
2056840
0
0
0
0
0
79626240
185
0
185894202
0
0
0
380671080
78708
0
88978
0
0
24
0
0
0
0
498074
0
0
2440704
106725170
17712112
0
0
0
0
0
201379222
12188
0
488262546
28
408
622508954
578327813
5201756
1656
0
0
10949184
0
0
0
619409843
0
0
473376
0
0
0
0
0
1...

result:

ok 999999 lines

Test #60:

score: 0
Accepted
time: 235ms
memory: 41284kb

input:

100 999998
)))(()()()(())())(((()))))()())()))())()()(((()()(())(()))((())))()((()))(()((((((()(())()())))((())
2 19 81 13
2 24 87 17
1 70 83 11
1 9 37 18
1 85 89 3
2 10 36 4
2 21 89 14
2 7 79 15
2 41 51 16
1 98 100 4
1 12 93 4
2 19 59 1
1 48 52 5
1 11 52 18
2 28 81 1
1 26 63 8
2 13 35 17
1 5 21 9
2...

output:

251239420
0
0
0
0
84120
831653327
62554891
0
0
157323234
25491
0
0
90893
995296
0
0
0
0
0
0
8572
405652480
0
316
253094353
991299633
0
0
48
0
229937623
7122154
205
0
357101192
4976640
2014
0
14437928
0
0
895419130
0
20736
42195200
1250658
156221420
38671191
0
0
0
0
0
681556604
10497
0
0
0
0
0
4299
4...

result:

ok 999998 lines

Test #61:

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

input:

100 999997
))))(())((())()()())())((()()))(())()((()()))()()(()))()(()))(((())(((()(()))))((()))()(((()(()())))
2 3 18 6
1 58 88 14
2 12 82 15
1 74 81 13
1 28 37 20
2 8 55 14
2 23 33 6
1 27 93 13
2 8 94 16
1 35 83 19
1 9 41 5
2 40 84 6
2 29 30 3
1 28 51 2
1 1 16 15
1 8 12 20
1 57 89 2
1 52 64 13
2 1...

output:

0
0
35502492
0
0
419904
0
27375924
3725198
0
268715
88956192
0
592
0
0
2701
0
0
0
1961774
0
218510
0
0
0
888949305
216
0
6
9487531
0
16768838
372322303
1920130
378947808
0
60257184
0
0
0
0
8640
0
0
0
31
0
1608
12693060
0
0
234
0
0
0
1938090
580135181
0
2592
0
725436
41129533
0
306
27171
0
11760336
0...

result:

ok 999997 lines

Test #62:

score: 0
Accepted
time: 235ms
memory: 41184kb

input:

100 999996
))))))())())))()(()())())((()))))((())))((()()(())))()()))())()())())()))((()((())))(()((((())(()))(
1 17 29 15
1 1 92 11
1 6 36 10
2 23 53 12
2 59 84 4
1 6 69 20
1 25 73 7
1 71 75 3
1 44 61 19
2 62 84 11
1 98 100 2
1 14 62 7
2 3 11 17
1 54 58 6
1 8 13 5
2 69 86 4
1 12 48 2
2 4 18 14
1 51...

output:

0
150469406
0
0
77934
0
63729764
0
0
0
0
44712724
0
0
0
0
2846
0
0
0
0
119117490
0
0
0
0
0
116582842
0
180
0
214839562
0
111052
0
0
0
381460659
0
0
0
0
0
991992233
0
352979303
0
25
597055208
88990
63000
341112384
0
0
9408528
0
772297151
0
638555921
0
0
0
0
2
135032
3909340
0
14
0
0
0
0
313658109
0
0...

result:

ok 999996 lines

Test #63:

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

input:

100 999995
)(())(())()))()(())))))((())))))(()()())()))()(()())))((((()()(()())(()(()(()))()))))())))(()()))()(
2 16 63 8
2 2 34 8
1 19 65 5
2 29 65 20
2 35 91 8
1 12 76 11
1 9 31 11
1 31 49 18
1 18 98 3
1 21 40 2
1 51 91 12
2 40 83 20
1 81 93 12
2 65 83 18
1 1 25 15
1 17 63 15
2 7 56 7
2 61 63 18
1...

output:

56230352
0
2047358
0
679450797
771291932
0
0
3586073
271
0
0
0
0
0
0
372956350
0
0
597196800
0
0
0
50547236
1280
7006
0
0
0
0
0
0
1173952
0
143762967
943743053
373825067
0
0
492790974
0
0
0
100902432
0
641751679
20661
812812
0
3686400
7747043
721877
30712464
0
0
0
0
2093760
0
0
0
0
0
0
0
130776
0
53...

result:

ok 999995 lines

Test #64:

score: 0
Accepted
time: 233ms
memory: 41540kb

input:

100 999994
)(((()))((((((()()))(()()((((((()(((()(())(()()()())(((()))))()(()())((()))()(((()()(()()(()()())))(
1 15 93 13
2 12 69 9
2 43 90 4
2 1 2 19
2 30 71 20
2 15 90 17
1 30 53 3
2 34 79 12
1 51 78 2
1 23 62 1
1 7 88 9
1 4 70 5
2 59 78 10
2 72 100 6
1 40 93 9
1 41 66 11
2 7 65 16
2 11 15 15
2 2...

output:

996257460
318415837
48811809
0
0
907736325
3395
345600
1359
253
724674125
226582802
0
143896
807281776
0
0
0
0
0
0
0
0
0
0
137557960
0
0
0
1202916
0
0
0
254116
0
904
0
0
0
0
427322514
0
0
0
6682032
0
272970694
0
0
0
0
791801043
0
208
0
76
0
30431
5688931
2258304
693147713
141
0
398706
0
0
0
0
895027...

result:

ok 999994 lines

Test #65:

score: 0
Accepted
time: 226ms
memory: 41364kb

input:

100 999993
)(((()()()((())()))(((()()))((((())(((()(()((()()))()(())(())))()))((()(()(())))))(((((()))))())(()(
2 10 19 14
2 3 13 2
2 22 60 15
2 51 65 18
1 18 62 5
2 9 21 7
1 36 92 12
2 12 26 6
2 9 27 1
2 2 10 12
1 62 69 2
1 26 100 6
2 29 56 16
2 29 67 18
1 52 81 19
2 15 27 19
1 20 55 12
2 58 74 19
...

output:

0
128
0
0
3729426
0
11943936
0
1575
0
0
49985042
0
0
0
0
0
0
4868
86418962
43255961
0
0
0
0
0
660125000
0
0
0
0
65
0
0
3
0
518818644
0
0
0
0
159
0
0
165888
0
0
0
0
0
547998
0
30507673
0
468
2475
0
826115159
0
0
0
0
0
0
0
0
0
414720
830185497
0
179159040
0
0
129042
792
270
0
0
0
0
0
0
710046
0
648
32...

result:

ok 999993 lines

Extra Test:

score: 0
Extra Test Passed