You are given $$$n$$$ non-decreasing arrays of non-negative numbers. Vasya repeats the following operation $$$k$$$ times:   Selects a non-empty array.  Puts the first element of the selected array in his pocket.  Removes the first element from the selected array. Vasya wants to maximize the sum of the elements in his pocket.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n, k \le 3\,000$$$): the number of arrays and operations. Each of the next $$$n$$$ lines contain an array. The first integer in each line is $$$t_i$$$ ($$$1 \le t_i \le 10^6$$$): the size of the $$$i$$$-th array. The following $$$t_i$$$ integers $$$a_{i, j}$$$ ($$$0 \le a_{i, 1} \le \ldots \le a_{i, t_i} \le 10^8$$$) are the elements of the $$$i$$$-th array. It is guaranteed that $$$k \le \sum\limits_{i=1}^n t_i \le 10^6$$$.

Print one integer: the maximum possible sum of all elements in Vasya's pocket after $$$k$$$ operations.

Input:
3 3
2 5 10
3 1 2 3
2 1 20

Output: 26

Input:
3 5
3 1 1000 100000000
2 1 100000000
3 99999999 100000000 100000000

Output: 400000000

Input:
1 1
1 87246905

Output: 87246905

Input:
1000 1000
65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 0
50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

Output: 0

Input:
1000 1000
321 0 0 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 1 1 1 1 1 1 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 ...

Output: 6241

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

Output: 5022

Input:
10 20
2 12 77
14 16 27 28 35 37 38 45 51 63 69 72 92 93 100
6 5 42 51 58 74 76
9 20 22 28 48 61 70 73 88 91
18 1 4 7 9 13 15 18 18 23 32 46 60 73 78 89 99 99 100
6 2 14 31 50 71 96
16 5 7 9 9 21 25 26 32 52 54 57 65 67 86 91 92
11 17 17 30 33 37 39 41 57 70 91 99
12 4 5 20 23 26 30 38 39 51 56 58 89
6 29 34 45 70 75 96

Output: 1115

Input:
1 100
100000 717 1522 2592 2895 3542 3974 5395 5603 5625 9701 10549 10884 11091 11397 12482 13186 16198 16338 18377 19218 21031 21203 21764 23942 24420 25998 27757 28563 30498 31228 32412 32978 33227 33547 33867 34634 36006 36073 36867 38709 38753 41381 44873 45103 45149 46265 46617 49298 49576 50083 50368 52091 52399 52428 53142 56332 58516 60959 61945 62534 65241 65304 65345 65767 66443 66821 66956 69794 70250 70753 70814 71141 74645 75397 78259 80122 80256 80875 84762 85083 86046 90147 90445 92835 9421...

Output: 5245138

Input:
2 100
63297 2320 4002 6199 6234 7600 11784 13234 15206 17919 20067 20221 21602 21611 24358 26977 27158 28708 29631 32169 33060 34199 34901 35039 38352 42361 48309 48913 49106 49388 54302 56725 60071 60373 65883 66075 66739 79506 80990 81035 81597 85339 85656 86669 90826 91317 91874 97766 97811 99447 99906 100693 100739 103447 110653 111239 111825 112352 117111 118667 123247 123794 124198 125026 126785 127198 128040 129358 131181 133814 134207 136914 138645 140114 140472 142762 143096 143966 145710 147234 ...

Output: 14602207

Input:
3000 3000
108 2503747 2922326 4533793 8385150 9145586 9995690 10739062 12416856 13567962 13908039 15159781 15164283 15526616 15881152 19825940 20845377 21062724 22782545 25053474 26652251 26940619 27701050 30423372 30474685 30680532 33500637 33537983 33590869 33888762 34337274 35734492 36051294 36406431 36426299 37248975 37564756 38447418 41006912 41139234 41482588 42694740 43925548 44170735 44673225 45939169 46457111 46978148 48108629 48158320 48341886 48620025 48696298 49056183 50689910 50717145 5204465...

Output: 173789317424

Input:
3000 3000
71 899258 972493 1387257 5204078 8926342 8959652 9994197 10945577 11023171 14033578 14153551 14746888 19839590 20764793 21434946 22009226 23035220 24151396 27814710 27867981 28415200 30693378 32692986 32880726 34685802 34770087 34945088 35387095 35511532 36056435 37789265 38166814 39183958 42412728 42530960 42757698 43042573 43274723 43505938 46141222 47360795 48539119 49927176 56672746 58253535 58556594 59496729 61343801 62247886 63485742 66971898 67058238 70724979 74876293 78011622 78025257 81...

Output: 175078235609

Input:
3000 2999
330 123761 463962 956302 1971429 2069314 2215368 3275626 3782939 4232589 4450995 4551548 4851560 5001213 5182040 5357557 5905992 6605044 6646116 6915550 7055676 7163274 7198766 7399240 7490652 7587776 7846222 8033337 8078149 8898530 9254193 9260252 9559048 9912732 10643434 11158173 11431846 11465925 11556922 11659912 11927834 12379437 12456884 12498269 12751607 12975145 13004265 13180063 13265620 13266543 13493431 13758459 14056723 14088924 14123534 14197134 14747889 14956433 15049144 15095606 1...

Output: 162040089693

Input:
3000 3000
30 3175884 9381391 10511604 14457137 17430546 17665610 19969537 21556445 26948619 31693683 36439550 41779572 52075262 57102515 57915344 58725458 63978960 68369226 71761155 71964117 76655944 80960552 83531321 83626043 86798930 87586234 89210876 92718668 97716855 99372291
62 1056968 6423620 6635885 6689372 9069774 10401213 12476834 13724909 13950583 14053412 14849924 17301214 22786279 24873708 25521472 25930254 28158241 28348855 33201571 36978645 41525157 41971716 43145889 44321243 44543808 45006...

Output: 175032203091

Input:
3000 2999
264 2063208 2540895 2562831 3002131 3408952 3602681 5341752 5778006 6164244 6604084 6632901 7608341 8372369 9012469 9301730 9518975 9559783 9743997 9883054 9910859 10829068 11335842 11913574 12316153 13177461 13974982 14205026 14503426 14773074 15076391 16004361 17425700 17670010 18511809 18532880 18714665 18872941 19424696 19460268 19533785 19598464 19711649 19875839 20176815 20206996 20573936 21513605 22069178 22555289 22700151 22982655 23052943 23247867 23420105 23576789 24236882 24450324 245...

Output: 163263817427

Input:
3000 3000
162 603843 968816 1885167 1933158 2877319 2954507 3071832 3767081 3874247 4124667 4713949 4783410 6499238 6508325 6816210 8407892 9569333 10192415 10842422 10844073 11237040 11613667 12012229 12078394 12540576 13426213 14301062 15072833 15362647 16453476 17455815 17507756 17517744 17829283 17917992 18350198 18465001 18655321 19228168 20932515 21049993 21341049 22594429 23587365 23967704 24443418 25249391 26850860 27842993 28947004 31748499 31913832 32420540 32588122 32756683 33995201 34306463 34...

Output: 175860757678

Input:
3000 2999
198 1353065 2337521 2672658 2842267 3821726 4641039 4748591 5400390 5480150 5857566 5982556 7561660 7735236 8010196 8365130 8443828 8553745 8588798 9135041 9850197 10390086 10885560 11314424 11566577 11911379 11998552 12954117 13737930 13757006 13990196 14349185 14351265 14487100 14736589 15564828 15802200 16200308 16435253 16744412 17016111 17303496 17597972 18733491 19480777 19555772 19640477 19776285 19957298 21047859 21168281 22022662 22079310 22510466 22732336 22770483 23004614 23314724 234...

Output: 167510866519

Input:
3000 3000
231 169111 174990 895833 1087525 1480082 3203027 3260715 3331975 3474671 4575965 4923873 5357953 6305143 6740251 7135297 8194837 8376887 8935649 9627481 10540422 10605376 10742443 10743687 12449630 13174181 13238142 13407086 13962972 14944130 15165780 15950283 15993654 16481912 17543030 17548390 17600188 19415215 19515162 19807819 19875143 20468610 21214858 21524135 22092193 22549187 23065470 23379712 25107088 25177200 26392058 27383419 27601325 27788932 28209711 28499571 28883916 29560922 29655...

Output: 180433440571

Input:
3000 2999
132 36883 640407 662261 1464041 1790141 2636608 4100089 4174396 4337990 6803598 10663667 10961643 11034603 11664270 12305689 12453276 12830657 14761901 14828948 14886723 15799886 17137191 20665483 20696509 21758739 22680573 23611290 23719250 25213123 28191595 30219921 33051137 33594917 33727002 34038594 35370298 35618432 35641998 35757085 36932791 37647097 38026415 38380859 38770120 39160649 39822935 40096649 40338094 40425101 40638591 40646436 44254672 46590950 47554114 48000976 48397904 484199...

Output: 169729084740

Input:
3000 3000
81 677860 2751983 3446800 3483933 5331427 5428600 6287551 7602946 7939721 8948142 10343789 12594756 13805573 14768549 14999040 17802645 20076145 21735208 22054332 23479133 25314802 25745192 25967843 26638343 27675787 28005545 28089124 28296906 29684188 30920414 31572245 32165730 33874538 34229893 34714501 40110079 40896399 41189143 41948115 42157070 43230610 47231822 49131704 50376631 53450311 54206454 55732182 56060907 56459465 57986567 58881934 59654599 60801498 60829443 63457595 67709720 6957...

Output: 184947737411

Input:
3000 2999
66 1100736 2815005 2950256 4025686 4607493 5433631 5522088 6498776 7910232 10179156 10490717 10976550 11310665 11789025 14292917 21392621 27440884 27604898 29555558 32346401 35439023 37728624 38233851 38645337 40023874 41950468 41968930 43217231 43763937 45400044 47343048 48311473 48795146 48901445 48936460 49533847 50519286 53503829 55714420 56405066 56417154 57341254 58947148 59314897 60806782 62770550 62937745 63738862 64033148 64214489 64490637 65679681 66888530 67806689 71556125 74491357 75...

Output: 175615549344

Input:
3000 3000
100 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1...

Output: 3001925

Input:
2000 2000
900 245397 348245 380692 431125 490500 588457 677269 734233 1122234 1470008 1484275 1656649 1660175 1801224 1842404 2141545 2181987 2470166 2538039 2714095 2788966 2890438 2943716 2973709 3002294 3048143 3087350 3163742 3181345 3229423 3417201 3535485 3808626 3873214 3873560 3896244 3913383 4275024 4524024 4620207 4632909 4780399 5354138 5365610 5504443 5851347 5897541 5978760 6003813 6073361 6094137 6153699 6161147 6164456 6213345 6231904 6393067 6428303 6659935 6670779 6677243 6740100 6748583 ...

Output: 114535571543

Input:
2000 1999
330 4789 172684 595156 703312 710090 1146397 1315791 1325322 1553222 1882150 1994082 2975369 3095736 3104939 3399459 3426477 3795931 4360423 4898570 4992222 5243404 5245329 5447122 5586706 5718329 5830259 6811999 6840110 7200667 7839517 8136776 8326583 9051346 9308587 9624443 10140934 10350324 11165881 12033921 12400391 12782464 13240835 13853209 14068838 15344486 15363735 15663116 15809871 16109193 16902420 17314866 17573361 17633356 18026350 18101827 18654054 18848618 18914899 18933809 1959181...

Output: 108248733951

Input:
2000 2000
359 184638 652089 953606 1035442 1487831 1519064 1939845 1961234 2332038 2371395 3499007 3611605 3630492 4295741 4561075 4591686 4752527 4865032 4937115 5072821 5073054 5660459 5667640 5967951 6064567 6288907 6390240 6422362 6839087 7030082 7425234 8481683 8581355 8865766 8911047 8950975 9066727 9379565 9449829 9679118 9770498 10142210 10185632 10923717 11256545 12065344 12564803 12645577 12804491 12903006 12926736 13590454 13868017 14186150 14269028 14533750 15384939 15828860 16626189 16864995 ...

Output: 115223501053

Input:
2000 1999
264 27586 185575 309288 450872 825272 938467 1460405 1781480 2014950 2472107 3566159 4170428 4468708 4738392 4860302 4969801 5021923 5198221 5199584 5916913 6210978 6258667 6507669 6666735 6730800 6906568 7153998 7266384 7599255 7736857 7778475 8113402 8751262 8863267 8909492 8960286 8997003 9445147 9531118 9941935 10056201 10551863 10971392 11371782 11636726 11892910 12300428 12442925 12519430 12629945 12686705 12936925 13137880 13303433 13663884 13816591 13968787 14217021 14299393 14359663 152...

Output: 106864097201

Input:
2000 2000
123 696669 924982 1309231 2411743 3172110 3310790 4325783 6088773 6700236 7825023 9330813 13573198 14252033 15719665 15791719 16352886 17532914 17878349 18218939 19177707 19348871 20042343 22508326 22635297 22649300 23182543 24096736 24373188 25148124 25240314 25505917 25611280 27432789 30109047 32331301 32715256 32839297 33015279 33953250 35153097 35965723 36439172 37225031 37368418 38326501 38437202 38949127 40299071 40467320 42030538 43687395 43967488 45606724 46251794 46662703 47138328 47195...

Output: 116321745728

Input:
2000 1999
198 103862 181344 459574 935863 935909 993617 1229311 1312026 1745135 2631488 3080683 3483911 3629268 4523566 4634129 5428174 5629233 5909572 6066654 6561423 7218944 7472038 7509077 7518360 8750651 8955729 9027540 9042985 9492849 9573670 10179113 11446315 12977741 14572137 15369142 16561557 17694376 17969411 19303296 19727267 20444721 22187792 23191027 23679981 23896528 24598239 24658583 24712348 25464721 25661366 26203525 26430680 26481344 26800335 26961180 27340926 27621230 27976234 28344054 2...

Output: 111722212727

Input:
2000 2000
16 5987994 11852843 15201843 28554295 34534431 38145134 38990308 39281258 46967821 50303896 55232696 59013320 76817244 80141889 84336095 88184075
297 215705 851810 1232534 1437722 1901604 3419253 4244947 4470809 4572032 4680792 4886724 5813211 6006488 6296738 6387864 7087521 7186846 8039437 8437035 8465625 8668238 8722777 9365213 10264213 10963387 10996678 11136722 11841341 11967841 12023274 12087229 12543358 12604057 12615735 12900945 13167888 13452137 13553124 13582608 13737970 14277023 14410...

Output: 116914664737

Input:
2000 1999
132 38256 474849 1319151 2740605 3929137 4230233 4258077 4437930 5099696 7242683 7809810 11811541 12184507 12537518 12711263 13925746 15300136 15735512 15801791 16583919 17327628 18295781 18473662 19953141 21077840 21254881 21654413 21980914 22389498 22948753 23328802 23624086 25186493 27192187 27289251 27347849 29370508 31523284 31670619 32970513 33061658 33167804 34116771 34421010 35406316 35810629 36054057 36386889 36635152 38279743 38553229 38962901 39075117 39178111 39676864 39841030 402916...

Output: 112900216936

Input:
2000 2000
123 1095487 1839779 2557689 3682657 4182558 5753719 5794559 6604514 7070904 8031269 9982592 10314283 10918463 11894922 12581481 14278538 14402282 14629998 15728186 16546502 17895478 17934919 18305440 19412378 19557423 19772500 20212378 23277508 24093753 25502126 26767704 27739191 28683959 29396791 29666229 29686587 30106807 30711310 30725067 31498762 31653143 31736265 31941551 32654331 33101668 33431012 33821642 33836235 35548312 38577660 39216168 39260890 39283400 40397836 41389654 41410201 426...

Output: 122206343535

Input:
2000 1999
66 3119554 3927598 4209417 4744807 8780015 9483615 12195826 12344101 13098945 13150080 14188147 17610764 20106454 22399147 22994389 23219836 24550474 25910945 26807942 27406783 27678895 28623191 28827525 30065735 31768655 32358443 33618064 34278503 36691379 40141425 44456728 51409221 53394783 54349243 54667176 57734519 59231624 60645204 61450205 62696065 65006185 65220679 65635388 66062738 67410081 67439505 71499254 71976627 75596191 75882658 77146414 78202284 80619359 82498340 85121147 86707273...

Output: 117349635084

Input:
2000 2000
64 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001
157 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 10...

Output: 2001272

Input:
1000 1000
432 66169 619478 652258 1010536 1530816 2342383 2550430 2782633 2980856 3295030 3548241 3955496 4301568 4352780 4441740 4498829 4726945 4929443 5073343 5328216 5339718 5406787 5727213 6022254 6087421 6269277 6335381 7061658 7133334 7260527 7353145 7511564 7591516 7728276 7884708 7932176 7985713 7991954 8358086 9011281 9086320 9839442 9989316 10028103 10105344 10342248 10934576 11093744 11417414 11616228 12698316 12742882 13000905 13304145 13699162 14100100 14307411 14320375 14815743 14865332 150...

Output: 55782956992

Input:
1000 999
330 33326 510619 1746129 1807800 1945684 2363781 2474795 2585716 2683376 2792226 3102168 3399454 3662386 4068081 4807543 5084126 5240499 5246483 5261407 5541242 6002734 6188908 6203870 7008881 7636589 7723237 7965247 8441253 8744110 9010931 9232273 9516365 10093760 10176639 10223247 10699205 10861299 11101963 11376042 12090083 12327780 12533270 12729939 12968309 13426262 13432194 13664165 13743663 13861832 14242091 14822617 15663280 15933621 16007456 16029459 16411733 16985388 17529665 18003906 1...

Output: 55157446468

Input:
1000 1000
35 3172611 9142027 12435054 12528946 12688045 13275822 15390086 23076993 25163779 26107049 28627438 31025086 34590574 34940469 35332726 38351178 44599087 49597156 49764810 51050072 51652217 56539613 59165639 61680698 64381780 68268968 75861547 76888506 80834693 84292574 84697422 85511798 88207310 90184388 92452810
157 149750 1862920 1974515 2355636 2889510 3054122 3177159 3351579 3631085 4480737 6464272 7311428 7542926 8440460 8866726 12244236 12317265 12940405 13648648 14798631 14807077 157025...

Output: 56573735434

Input:
1000 999
264 168572 507888 1050995 1880198 2273983 2397665 3604706 3934709 4007010 4281971 5001191 5084732 5126480 5331471 5680367 5962003 6847598 7197971 7552646 7824891 8101184 8193944 8314669 9244583 9364513 9524947 9789459 10190064 10212294 10280619 10366868 10921958 11594601 11785349 12911108 13091601 13203232 13995249 15106756 15191514 16092210 16893269 18079299 18203149 18794491 18812619 18934135 19643672 20337708 20723797 20892770 21226129 21273290 21393564 21975798 23746349 24006113 24669805 2596...

Output: 53110157215

Input:
1000 1000
730 241640 457995 726673 742230 941313 1393503 1541426 1624268 1943703 2072049 2308863 2468003 2640907 2690850 2703408 2933519 3087558 3130847 3142120 3233478 3276746 3312551 3339527 3440561 3520304 3536766 3537577 3607800 3645777 3646994 3732068 3817993 4564091 4630488 4733584 4738992 4775966 4913045 4980596 5071585 5225434 5237187 5434777 5522660 5701163 5751811 5904938 6000371 6084966 6109527 6158031 6228953 6309467 6410641 6791452 6791924 7203163 7306399 7374088 7698692 7729794 7976160 81943...

Output: 56947429626

Input:
1000 999
198 36209 278559 293089 670615 1315832 1991363 2080222 2327221 2427364 3193250 3702273 3791582 3893630 4241275 4285464 4303522 4702707 4917706 6902306 7106837 7388733 7569200 7600354 9132825 10184167 10903644 11321715 11408371 11450554 11712326 11792908 12157222 12313920 12381971 12953202 15383291 15544404 15606411 16049470 16729305 16893225 19396352 20423746 20807924 21194268 21738155 21788140 21825939 21971629 22671346 22802208 23348421 23404051 23465503 23559056 25031918 26350301 26434756 2653...

Output: 55372961251

Input:
1000 1000
586 392429 427283 836584 858318 980951 1336134 1365425 1366415 1428026 1974702 2090021 2235407 2535436 2580741 3009138 3215641 3221392 3840821 4004572 4192817 4595801 5005201 5291467 5358301 5461121 5709070 5856651 5876050 6113651 6485634 6588749 6871036 7184444 7276181 7473650 7528636 7624477 7653585 7686779 8095575 8115103 8234078 8354113 8414859 8725313 8808471 9045848 9319460 9519889 9529479 9742271 9855777 10134401 10321814 10576460 10839503 11006423 11889674 11895273 11994067 11998364 1218...

Output: 58227573568

Input:
1000 999
132 53281 757746 1794447 1991931 2266046 2332641 2356052 2483150 2765336 2974202 3162350 3245944 3479006 5812461 6930190 7117548 7568696 9065266 10336137 12568854 12960970 14360695 15230003 15908602 16062106 17697381 18216710 18445484 18550576 19609222 19638625 19718690 20368616 20460391 20818893 24613413 24793230 26112932 26552040 27362287 29888541 30361390 30456192 30761182 30920729 31513915 31533814 33907770 33938221 35896292 36345987 36639580 37584719 38563855 41384259 42063544 42080740 42184...

Output: 55775185704

Input:
1000 1000
57 3188370 3538182 4128759 7384540 9086139 10535313 12009666 12409030 13486062 18206122 20546774 21870389 23676594 25176604 26004784 28193741 30460851 32180794 35826968 38923637 39620766 40670543 41811002 42215273 42856158 43707734 44086703 44609700 51655690 51916767 56078719 58425755 60634041 62011459 65935578 66598338 67605983 68344693 68825606 68972801 70275533 74951265 74976332 75699998 77317987 84528753 86339196 87399930 89154133 89233551 89284705 90181002 93337362 94540639 99754665 9981956...

Output: 59125199938

Input:
1000 999
66 3594432 8175902 12541682 14393716 16355670 16610339 17236703 18219404 19027736 19613633 19699034 19992533 23290881 24685048 25108203 25630065 30564842 32169170 33115608 33434611 33981434 34129622 34818817 36404097 36441487 36635872 36846315 37235040 38774986 41142931 41805098 41865673 41993062 42048893 42413149 42950173 44963559 45158200 46836260 47524098 48432785 51602510 53625595 54782408 55534116 55945687 55952860 58245691 59626543 61904985 62142125 64756877 66846439 67564290 67605657 69408...

Output: 58139924254

Input:
1000 1000
591 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1...

Output: 1000611

Input:
3000 2999
2 23937874 99248021
2 20105784 51744075
2 48415978 85528236
2 33340231 35915942
2 35868172 54602866
2 47944457 55789959
2 63382166 66522118
2 7074475 92771885
2 48006804 67686918
2 31013347 82939068
2 40549519 94687660
2 57495829 95953009
2 32525808 40051208
2 50125732 62076058
2 35915167 41126664
2 16055564 20214771
2 81067805 89766024
2 23545731 57295835
2 52928005 70901657
2 57903586 66962908
2 3594581 91620654
2 38690932 62620818
2 6955589 55080196
2 51930530 67247450
...

Output: 201501401065

Input:
3000 2999
333 105273 286643 566113 940521 1544167 1992782 2109500 2288502 2599531 2645801 2917922 3241768 3446053 3557773 4237524 5140927 5643263 5697778 7303687 7309290 7485043 8290912 8326798 8620876 8852689 9279010 9310206 9679655 10189529 10937688 11363189 11577989 11637298 12333805 12529783 13185247 13260739 13472961 13709588 14287088 14545657 15323175 15658941 16380576 17295881 17534239 17918799 18231865 19471652 19576619 19726987 19939794 20135278 20206017 20321804 20695621 21196248 21389393 214384...

Output: 163790743513

Input:
3000 2999
368 646604 1284511 1300264 1717548 2057353 2146872 3004722 3159769 3287344 3530486 3671122 3903296 4175484 4329444 5459038 5482580 5849981 6025137 6553348 6610234 6654184 6759265 6982929 7018558 7106884 7234399 7397401 7720237 8045105 8155531 8164325 8363191 8449043 8995539 9002051 9011027 9464177 9698419 9951411 10073760 10151412 10284683 10323312 10811436 11075701 11345340 12511076 12549364 12644253 13104905 13181209 13326976 13484569 13549042 14708357 15983742 16043436 16237014 16354028 17565...

Output: 166287122729

Input:
2 11
10 1 1 1 1 1 1 1 1 1 100000
20 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100

Output: 100109


Prof. Vasechkin wants to represent positive integer n as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent 121 as 121=111+11+–1. Help him to find the least number of digits 1 in such sum.

The first line of the input contains integer n (1 ≤ n < 1015).

Print expected minimal number of digits 1.


Two-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, "AZ", "AA", "ZA" — three distinct two-grams.You are given a string $$$s$$$ consisting of $$$n$$$ capital Latin letters. Your task is to find any two-gram contained in the given string as a substring (i.e. two consecutive characters of the string) maximal number of times. For example, for string $$$s$$$ = "BBAABBBA" the answer is two-gram "BB", which contained in $$$s$$$ three times. In other words, find any most frequent two-gram.Note that occurrences of the two-gram can overlap with each other.

NoteIn the first example "BA" is also valid answer.In the second example the only two-gram "ZZ" can be printed because it contained in the string "ZZZAA" two times.

The first line of the input contains integer number $$$n$$$ ($$$2 \le n \le 100$$$) — the length of string $$$s$$$. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ capital Latin letters.

Print the only line containing exactly two capital Latin letters — any two-gram contained in the given string $$$s$$$ as a substring (i.e. two consecutive characters of the string) maximal number of times.

Input:
7
ABACABA

Output: BA

Output: AB

Input:
5
ZZZAA

Output: ZZ

Input:
26
QWERTYUIOPASDFGHJKLZXCVBNM

Output: KL

Output: QW

Output: WE

Output: AS

Input:
2
QA

Output: QA

Input:
2
WW

Output: WW

Input:
11
GGRRAATTZZZ

Output: ZZ

Input:
50
NYQAHBYYOXLTRYQDMVENEMAQNBAKGLGQOLXNAIFNQTOCLNNQIA

Output: NQ

Output: YQ

Input:
100
URXCAIZFIBNJTPCZHBQIBCILLPXZCFGMKKZMNPLCYGAVJVIBMCZEBSJWPSCPQDYCTTKPOKIJRSKIZPDGCHVOUTMPNECYORSFZFNC

Output: IB

Input:
100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Output: AA

Input:
10
SQSQSQSQTG

Output: SQ

Input:
5
AZAZA

Output: ZA

Output: AZ

Input:
15
MIRZOYANOVECLOX

Output: AN

Output: IR

Output: MI

Output: NO

Input:
9
EGORLETOV

Output: GO

Output: EG

Output: TO

Input:
8
PUTINVOR

Output: PU

Output: IN

Output: UT

Output: NV

Input:
7
KADUROV

Output: KA

Output: AD

Input:
6
AZAZAZ

Output: AZ

Input:
3
LOL

Output: OL

Output: LO

Input:
3
KEK

Output: EK

Output: KE

Input:
5
FUFEL

Output: UF

Output: EL

Output: FU

Input:
9
MIKEPIDOR

Output: EP

Output: MI

Output: DO

Output: IK

Input:
9
AAAAAAAAA

Output: AA

Input:
23
AABBBAAACCCCCAAADDDDDDD

Output: DD


You are given two positive integers $$$x$$$ and $$$y$$$. You can perform the following operation with $$$x$$$: write it in its binary form without leading zeros, add $$$0$$$ or $$$1$$$ to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of $$$x$$$.For example:   $$$34$$$ can be turned into $$$81$$$ via one operation: the binary form of $$$34$$$ is $$$100010$$$, if you add $$$1$$$, reverse it and remove leading zeros, you will get $$$1010001$$$, which is the binary form of $$$81$$$.  $$$34$$$ can be turned into $$$17$$$ via one operation: the binary form of $$$34$$$ is $$$100010$$$, if you add $$$0$$$, reverse it and remove leading zeros, you will get $$$10001$$$, which is the binary form of $$$17$$$.  $$$81$$$ can be turned into $$$69$$$ via one operation: the binary form of $$$81$$$ is $$$1010001$$$, if you add $$$0$$$, reverse it and remove leading zeros, you will get $$$1000101$$$, which is the binary form of $$$69$$$.  $$$34$$$ can be turned into $$$69$$$ via two operations: first you turn $$$34$$$ into $$$81$$$ and then $$$81$$$ into $$$69$$$. Your task is to find out whether $$$x$$$ can be turned into $$$y$$$ after a certain number of operations (possibly zero).

NoteIn the first example, you don't even need to do anything.The fourth example is described in the statement.

The only line of the input contains two integers $$$x$$$ and $$$y$$$ ($$$1 \le x, y \le 10^{18}$$$).

Print YES if you can make $$$x$$$ equal to $$$y$$$ and NO if you can't.

Input: 3 3

Output: Yes

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 7 4

Output: NO

Output: NO

Output: no

Output: No

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 2 8

Output: NO

Output: NO

Output: no

Output: No

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 34 69

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 8935891487501725 71487131900013807

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 470060730774588924 727173667167621133

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 95 427

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 985 1653

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 435 1515

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 1717 879

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 407 113

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 753 271

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 6261 668

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 2651 1994

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 4997 4748

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 407 3263

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 753 6031

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 2651 21215

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 4997 39983

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 4529535624500812 36236284996006503

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 3145302420099927 25162419360799423

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 2963671906804332 23709375254434663

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 1579442997370991 12635543978967935

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 8935891487501725 71986286270688669

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 9762130370617853 135862919936991741

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 3165137368662540 34690334760256012

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 3991380546745964 35516577938339436

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 272137586985970 17939699391684503

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 98376470102098 8668311108715159

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 968503512949840 70798422886785671

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 794746691033263 69408368311453055

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 469234491891472796 290944711594072288

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 470886973952672348 163402627036137273

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 942220828365 412458936303

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 642061520256 807582787377560508

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 662695912942035259 813128064161

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 592255623895602343 956231061252005500

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 100 201

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 100 403

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 5 55

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 26 47

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 5 10

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 90 180

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 10 11

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 11 13

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 11 27

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 10 576460752303423487

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 41 119

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 20 607

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 32 457

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 10 10

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 100 100

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 1 1125899906842623

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 4 4

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 114514 114514

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 1 576460752303423487

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 32 32

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 8 8

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 2 2

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 45454 45454

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 16 16

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 25 19

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 1 2147483647

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 6 1

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 13 11

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 88888888888888888 99999999999999999

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 20 20

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 10 5

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 44 44

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 4 5

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 8 1

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 2 1

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 54043195528445952 3

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 1048576 1048576

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 44 29

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 23654897456254158 36584562123658749

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 1 67108863

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 999999999999999999 864691128455135231

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 18014398509481984 54043195528445952

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 22 107

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 12312 12312

Output: YES

Output: YES

Output: YES

Output: yes

Output: YES

Output: Yes

Output: yEs

Output: yES

Output: YES

Input: 2 6

Output: NO

Output: NO

Output: no

Output: NO

Output: NO

Output: NO

Output: NO

Output: No

Output: NO

Input: 22 11

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 42 2193386110975

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 34 17

Output: YES

Output: YES

Output: YES

Output: YES

Output: Yes

Output: YEs

Output: yES

Output: YES

Input: 9 43

Output: NO

Output: NO

Output: No

Output: NO


Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: $$$1$$$, $$$4$$$, $$$8$$$, $$$9$$$, ....For a given number $$$n$$$, count the number of integers from $$$1$$$ to $$$n$$$ that Polycarp likes. In other words, find the number of such $$$x$$$ that $$$x$$$ is a square of a positive integer number or a cube of a positive integer number (or both a square and a cube simultaneously).

The first line contains an integer $$$t$$$ ($$$1 \le t \le 20$$$) — the number of test cases. Then $$$t$$$ lines contain the test cases, one per line. Each of the lines contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

For each test case, print the answer you are looking for — the number of integers from $$$1$$$ to $$$n$$$ that Polycarp likes.

Input:
6
10
1
25
1000000000
999999999
500000000

Output:
4

1

6

32591

32590

23125

Output:
4
1
6
32591
32590
23125

Output:
4
1
6
32591
32590
23125

Output:
4

1

6

32591

32590

23125

Output:
4
1
6
32591
32590
23125

Output:
4
1
6
32591
32590
23125

Output:
4
1
6
32591
32590
23125

Output:
4
1
6
32591
32590
23125

Output: 4 1 6 32591 32590 23125

Output: 4 1 6 32591 32590 23125

Output:
4
1
6
32591
32590
23125

Input:
20
1
2
3
4
5
6
7
8
9
10
6012
975
3916
4805
7952
3301
647
3799
8657
122

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Output: 1 1 1 2 2 2 2 3 4 4 91 37 74 81 104 68 31 73 109 13

Output: 1 1 1 2 2 2 2 3 4 4 91 37 74 81 104 68 31 73 109 13

Output:
1

1

1

2

2

2

2

3

4

4

91

37

74

81

104

68

31

73

109

13

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Output:
1

1

1

2

2

2

2

3

4

4

91

37

74

81

104

68

31

73

109

13

Output:
1
1
1
2
2
2
2
3
4
4
91
37
74
81
104
68
31
73
109
13

Input:
20
1000000000
999999999
999999998
999999997
999999996
999999995
999999994
999999993
999999992
999999991
999999990
999999989
999999988
999999987
999999986
999999985
999999984
999999983
999999982
999999981

Output: 32591 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output: 32591 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590

Output:
32591

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32591

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

Output:
32591
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Input:
1
8000

Output: 105

Output: 105

Output: 105

Output: 105

Output: 105

Output: 105

Output: 105

Output: 105

Output: 105

Input:
4
64000000
85766121
113379904
148035889

Output:
8380
9681
11110
12673

Output:
8380
9681
11110
12673

Output:
8380

9681

11110

12673

Output: 8380 9681 11110 12673

Output:
8380
9681
11110
12673

Output:
8380
9681
11110
12673

Output:
8380
9681
11110
12673

Output:
8380
9681
11110
12673

Output:
8380
9681
11110
12673

Output:
8380

9681

11110

12673

Input:
20
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000

Output:
32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Output: 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591 32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Output:
32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Output:
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591
32591

Input:
1
5000

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Input:
1
64

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Input:
1
216

Output: 18

Output: 18

Output: 18

Output: 18

Output: 18

Output: 18

Output: 18

Output: 18

Input:
2
8000
5000

Output:
105
83

Output:
105
83

Output:
105

83

Output:
105
83

Output:
105
83

Output:
105
83

Output:
105

83

Output:
105
83

Output: 105 83

Output:
105
83

Input:
1
997002999

Output: 32543

Output: 32543

Output: 32543

Output: 32543

Output: 32543

Output: 32543

Output: 32543

Output: 32543

Input:
1
1000000

Output: 1090

Output: 1090

Output: 1090

Output: 1090

Output: 1090

Output: 1090

Output: 1090

Output: 1090

Input:
10
5050
30404
12345
98765432
1234564
64
456
1
23
123

Output:
84

200

130

10379

1208

10

26

1

5

13

Output: 84 200 130 10379 1208 10 26 1 5 13

Output:
84
200
130
10379
1208
10
26
1
5
13

Output:
84
200
130
10379
1208
10
26
1
5
13

Output:
84
200
130
10379
1208
10
26
1
5
13

Output:
84
200
130
10379
1208
10
26
1
5
13

Output:
84

200

130

10379

1208

10

26

1

5

13

Output:
84
200
130
10379
1208
10
26
1
5
13

Output:
84
200
130
10379
1208
10
26
1
5
13

Output:
84
200
130
10379
1208
10
26
1
5
13

Input:
2
5000
8000

Output:
83
105

Output: 83 105

Output:
83
105

Output:
83
105

Output:
83
105

Output:
83
105

Output:
83

105

Output:
83

105

Output:
83
105

Output:
83
105

Input:
7
64000000
85766121
113379904
148035889
191102976
244140625
594823321

Output:
8380
9681
11110
12673
14376
16225
25201

Output: 8380 9681 11110 12673 14376 16225 25201

Output:
8380
9681
11110
12673
14376
16225
25201

Output:
8380
9681
11110
12673
14376
16225
25201

Output:
8380

9681

11110

12673

14376

16225

25201

Output:
8380

9681

11110

12673

14376

16225

25201

Output:
8380
9681
11110
12673
14376
16225
25201

Output:
8380
9681
11110
12673
14376
16225
25201

Output:
8380
9681
11110
12673
14376
16225
25201

Output:
8380
9681
11110
12673
14376
16225
25201

Input:
1
729

Output: 33

Output: 33

Output: 33

Output: 33

Output: 33

Output: 33

Output: 33

Output: 33

Input:
1
4096

Output: 76

Output: 76

Output: 76

Output: 76

Output: 76

Output: 76

Output: 76

Output: 76

Input:
1
26

Output: 6

Output: 6

Output: 6

Output: 6

Output: 6

Output: 6

Output: 6

Output: 6

Input:
20
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Output: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Output:
2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Output:
2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Output:
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2

Input:
2
1000
999

Output:
38
37

Output:
38
37

Output:
38
37

Output:
38

37

Output:
38
37

Output:
38
37

Output:
38

37

Output: 38 37

Output:
38
37

Output:
38
37

Input:
1
117649

Output: 385

Output: 385

Output: 385

Output: 385

Output: 385

Output: 385

Output: 385

Output: 385

Input:
20
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999
999999999

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Output: 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590 32590

Output:
32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

32590

Output:
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590
32590

Input:
20
50653
54872
59319
64000
68921
74088
79507
85184
91125
97336
103823
110592
125000
132651
140608
148877
157464
166375
175616
185193

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Output:
256

266

276

286

297

308

318

329

340

351

363

374

396

408

419

431

443

455

468

480

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Output: 256 266 276 286 297 308 318 329 340 351 363 374 396 408 419 431 443 455 468 480

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Output:
256

266

276

286

297

308

318

329

340

351

363

374

396

408

419

431

443

455

468

480

Output:
256
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468
480

Input:
6
4096
15625
46656
117649
262144
531441

Output:
76
145
246
385
568
801

Output:
76
145
246
385
568
801

Output:
76

145

246

385

568

801

Output:
76
145
246
385
568
801

Output: 76 145 246 385 568 801

Output:
76
145
246
385
568
801

Output:
76
145
246
385
568
801

Output:
76

145

246

385

568

801

Output:
76
145
246
385
568
801

Output:
76
145
246
385
568
801

Input:
18
54872
59319
64000
68921
74088
79507
85184
91125
97336
103823
110592
125000
132651
140608
148877
157464
166375
175616

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output: 266 276 286 297 308 318 329 340 351 363 374 396 408 419 431 443 455 468

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output:
266

276

286

297

308

318

329

340

351

363

374

396

408

419

431

443

455

468

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output:
266
276
286
297
308
318
329
340
351
363
374
396
408
419
431
443
455
468

Output:
266

276

286

297

308

318

329

340

351

363

374

396

408

419

431

443

455

468

Input:
2
8000
1000000

Output:
105
1090

Output: 105 1090

Output:
105

1090

Output:
105
1090

Output:
105

1090

Output:
105
1090

Output:
105
1090

Output:
105
1090

Output:
105
1090

Output:
105
1090

Input:
1
1000

Output: 38

Output: 38

Output: 38

Output: 38

Output: 38

Output: 38

Output: 38

Output: 38

Input:
10
3307949
3375000
3442951
3511808
3581577
3652264
3723875
3796416
3869893
3944312

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Output:
1955

1975

1994

2013

2033

2053

2072

2092

2112

2132

Output: 1955 1975 1994 2013 2033 2053 2072 2092 2112 2132

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Output:
1955

1975

1994

2013

2033

2053

2072

2092

2112

2132

Output:
1955
1975
1994
2013
2033
2053
2072
2092
2112
2132

Input:
6
64
729
4096
15625
46656
117649

Output:
10
33
76
145
246
385

Output:
10
33
76
145
246
385

Output:
10
33
76
145
246
385

Output:
10
33
76
145
246
385

Output:
10
33
76
145
246
385

Output:
10
33
76
145
246
385

Output:
10

33

76

145

246

385

Output: 10 33 76 145 246 385

Output:
10
33
76
145
246
385

Output:
10

33

76

145

246

385

Input:
7
100
1000
10000
100000
1000000
10000000
100000000

Output:
12
38
117
356
1090
3363
10443

Output: 12 38 117 356 1090 3363 10443

Output:
12

38

117

356

1090

3363

10443

Output:
12
38
117
356
1090
3363
10443

Output:
12
38
117
356
1090
3363
10443

Output:
12
38
117
356
1090
3363
10443

Output:
12
38
117
356
1090
3363
10443

Output:
12
38
117
356
1090
3363
10443

Output:
12
38
117
356
1090
3363
10443

Output:
12

38

117

356

1090

3363

10443

Input:
3
8000
1000
1000000

Output:
105

38

1090

Output:
105
38
1090

Output:
105
38
1090

Output:
105
38
1090

Output: 105 38 1090

Output:
105
38
1090

Output:
105
38
1090

Output:
105
38
1090

Output:
105
38
1090

Output:
105

38

1090

Input:
1
729000000

Output: 27870

Output: 27870

Output: 27870

Output: 27870

Output: 27870

Output: 27870

Output: 27870

Output: 27870

Input:
6
64
729
4096
117649
262144
531441

Output:
10
33
76
385
568
801

Output:
10
33
76
385
568
801

Output:
10
33
76
385
568
801

Output: 10 33 76 385 568 801

Output:
10

33

76

385

568

801

Output:
10
33
76
385
568
801

Output:
10
33
76
385
568
801

Output:
10
33
76
385
568
801

Output:
10

33

76

385

568

801

Output:
10
33
76
385
568
801

Input:
18
2515456
2571353
2628072
2685619
2744000
2803221
2924207
3048625
3112136
3176523
3307949
3442951
3511808
3581577
3652264
3796416
3869893
3944312

Output: 1711 1729 1748 1766 1785 1804 1842 1879 1898 1917 1955 1994 2013 2033 2053 2092 2112 2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Output:
1711

1729

1748

1766

1785

1804

1842

1879

1898

1917

1955

1994

2013

2033

2053

2092

2112

2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Output:
1711

1729

1748

1766

1785

1804

1842

1879

1898

1917

1955

1994

2013

2033

2053

2092

2112

2132

Output:
1711
1729
1748
1766
1785
1804
1842
1879
1898
1917
1955
1994
2013
2033
2053
2092
2112
2132

Input:
2
4096
64

Output:
76
10

Output:
76

10

Output:
76
10

Output:
76
10

Output:
76
10

Output:
76

10

Output: 76 10

Output:
76
10

Output:
76
10

Output:
76
10

Input:
5
10000
100000
1000000
10000000
100000000

Output:
117
356
1090
3363
10443

Output:
117
356
1090
3363
10443

Output:
117

356

1090

3363

10443

Output: 117 356 1090 3363 10443

Output:
117
356
1090
3363
10443

Output:
117
356
1090
3363
10443

Output:
117
356
1090
3363
10443

Output:
117
356
1090
3363
10443

Output:
117

356

1090

3363

10443

Output:
117
356
1090
3363
10443

Input:
5
1
64
729
4096
15625

Output:
1
10
33
76
145

Output:
1
10
33
76
145

Output:
1

10

33

76

145

Output:
1
10
33
76
145

Output:
1
10
33
76
145

Output:
1
10
33
76
145

Output: 1 10 33 76 145

Output:
1
10
33
76
145

Output:
1
10
33
76
145

Output:
1

10

33

76

145

Input:
1
887503681

Output: 30721

Output: 30721

Output: 30721

Output: 30721

Output: 30721

Output: 30721

Output: 30721

Output: 30721

Input:
3
8000
1000
100000000

Output:
105

38

10443

Output:
105
38
10443

Output:
105
38
10443

Output:
105
38
10443

Output:
105
38
10443

Output:
105
38
10443

Output:
105
38
10443

Output:
105

38

10443

Output: 105 38 10443

Output:
105
38
10443

Input:
5
4657463
4741632
4913000
5000211
5088448

Output:
2313
2333
2373
2394
2414

Output:
2313
2333
2373
2394
2414

Output: 2313 2333 2373 2394 2414

Output:
2313
2333
2373
2394
2414

Output:
2313

2333

2373

2394

2414

Output:
2313
2333
2373
2394
2414

Output:
2313

2333

2373

2394

2414

Output:
2313
2333
2373
2394
2414

Output:
2313
2333
2373
2394
2414

Output:
2313
2333
2373
2394
2414

Input:
1
4913

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Output: 83

Input:
8
117649
262144
531441
1000000
1771561
2985984
4826809
7529536

Output:
385
568
801
1090
1441
1860
2353
2926

Output: 385 568 801 1090 1441 1860 2353 2926

Output:
385
568
801
1090
1441
1860
2353
2926

Output:
385
568
801
1090
1441
1860
2353
2926

Output:
385
568
801
1090
1441
1860
2353
2926

Output:
385

568

801

1090

1441

1860

2353

2926

Output:
385

568

801

1090

1441

1860

2353

2926

Output:
385
568
801
1090
1441
1860
2353
2926

Output:
385
568
801
1090
1441
1860
2353
2926

Output:
385
568
801
1090
1441
1860
2353
2926

Input:
1
65

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Output: 10

Input:
3
1000
8000
1000000

Output: 38 105 1090

Output:
38
105
1090

Output:
38
105
1090

Output:
38
105
1090

Output:
38
105
1090

Output:
38

105

1090

Output:
38

105

1090

Output:
38
105
1090

Output:
38
105
1090

Output:
38
105
1090

Input:
1
512

Output: 28

Output: 28

Output: 28

Output: 28

Output: 28

Output: 28

Output: 28

Output: 28

Input:
16
8000000
8120601
8242408
8365427
8489664
8615125
8741816
8869743
8998912
9129329
9261000
9393931
9528128
9663597
9800344
9938375

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Output:
3014

3036

3058

3081

3103

3126

3148

3171

3193

3216

3239

3261

3284

3307

3330

3353

Output:
3014

3036

3058

3081

3103

3126

3148

3171

3193

3216

3239

3261

3284

3307

3330

3353

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Output: 3014 3036 3058 3081 3103 3126 3148 3171 3193 3216 3239 3261 3284 3307 3330 3353

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Output:
3014
3036
3058
3081
3103
3126
3148
3171
3193
3216
3239
3261
3284
3307
3330
3353

Input:
1
46656

Output: 246

Output: 246

Output: 246

Output: 246

Output: 246

Output: 246

Output: 246

Output: 246

Input:
3
4096
64
1000000000

Output:
76

10

32591

Output: 76 10 32591

Output:
76
10
32591

Output:
76

10

32591

Output:
76
10
32591

Output:
76
10
32591

Output:
76
10
32591

Output:
76
10
32591

Output:
76
10
32591

Output:
76
10
32591

Input:
8
64000000
85766121
113379904
148035889
191102976
244140625
594823321
887503681

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output:
8380

9681

11110

12673

14376

16225

25201

30721

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output: 8380 9681 11110 12673 14376 16225 25201 30721

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output:
8380
9681
11110
12673
14376
16225
25201
30721

Output:
8380

9681

11110

12673

14376

16225

25201

30721

Input:
12
64
125
216
343
512
729
1000
1331
1728
2197
2744
3375

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output:
10

14

18

23

28

33

38

44

50

56

63

70

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output: 10 14 18 23 28 33 38 44 50 56 63 70

Output:
10
14
18
23
28
33
38
44
50
56
63
70

Output:
10

14

18

23

28

33

38

44

50

56

63

70

Input:
5
9261000
9393931
9663597
9800344
9938375

Output:
3239
3261
3307
3330
3353

Output:
3239
3261
3307
3330
3353

Output:
3239
3261
3307
3330
3353

Output:
3239
3261
3307
3330
3353

Output: 3239 3261 3307 3330 3353

Output:
3239
3261
3307
3330
3353

Output:
3239
3261
3307
3330
3353

Output:
3239
3261
3307
3330
3353

Output:
3239

3261

3307

3330

3353

Output:
3239

3261

3307

3330

3353

Input:
7
4096
64
1000000000
15625
46656
262144
2985984

Output: 76 10 32591 145 246 568 1860

Output:
76
10
32591
145
246
568
1860

Output:
76

10

32591

145

246

568

1860

Output:
76
10
32591
145
246
568
1860

Output:
76
10
32591
145
246
568
1860

Output:
76
10
32591
145
246
568
1860

Output:
76

10

32591

145

246

568

1860

Output:
76
10
32591
145
246
568
1860

Output:
76
10
32591
145
246
568
1860

Output:
76
10
32591
145
246
568
1860

Input:
1
125

Output: 14

Output: 14

Output: 14

Output: 14

Output: 14

Output: 14

Output: 14

Output: 14

Input:
15
7762392
7880599
8000000
8120601
8242408
8365427
8489664
8615125
8741816
8998912
9129329
9261000
9393931
9663597
9938375

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2970

2992

3014

3036

3058

3081

3103

3126

3148

3193

3216

3239

3261

3307

3353

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2970

2992

3014

3036

3058

3081

3103

3126

3148

3193

3216

3239

3261

3307

3353

Output: 2970 2992 3014 3036 3058 3081 3103 3126 3148 3193 3216 3239 3261 3307 3353

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Input:
1
59319

Output: 276

Output: 276

Output: 276

Output: 276

Output: 276

Output: 276

Output: 276

Output: 276

Input:
9
8489664
8615125
8741816
8998912
9129329
9261000
9393931
9663597
9938375

Output:
3103

3126

3148

3193

3216

3239

3261

3307

3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
3103

3126

3148

3193

3216

3239

3261

3307

3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output: 3103 3126 3148 3193 3216 3239 3261 3307 3353

Input:
5
15625
97336
195112
205379
274625

Output:
145
351
492
505
581

Output: 145 351 492 505 581

Output:
145

351

492

505

581

Output:
145

351

492

505

581

Output:
145
351
492
505
581

Output:
145
351
492
505
581

Output:
145
351
492
505
581

Output:
145
351
492
505
581

Output:
145
351
492
505
581

Output:
145
351
492
505
581

Input:
1
728

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Input:
4
117649
262144
1000000
1771561

Output:
385

568

1090

1441

Output:
385
568
1090
1441

Output:
385

568

1090

1441

Output:
385
568
1090
1441

Output:
385
568
1090
1441

Output:
385
568
1090
1441

Output:
385
568
1090
1441

Output:
385
568
1090
1441

Output: 385 568 1090 1441

Output:
385
568
1090
1441

Input:
5
117649
262144
531441
1000000
1771561

Output:
385
568
801
1090
1441

Output:
385
568
801
1090
1441

Output:
385
568
801
1090
1441

Output:
385

568

801

1090

1441

Output: 385 568 801 1090 1441

Output:
385
568
801
1090
1441

Output:
385
568
801
1090
1441

Output:
385
568
801
1090
1441

Output:
385
568
801
1090
1441

Output:
385

568

801

1090

1441

Input:
7
728
1000
10000
100000
1000000
10000000
100000000

Output:
32
38
117
356
1090
3363
10443

Output:
32

38

117

356

1090

3363

10443

Output:
32
38
117
356
1090
3363
10443

Output:
32
38
117
356
1090
3363
10443

Output:
32
38
117
356
1090
3363
10443

Output:
32
38
117
356
1090
3363
10443

Output:
32
38
117
356
1090
3363
10443

Output:
32

38

117

356

1090

3363

10443

Output:
32
38
117
356
1090
3363
10443

Output: 32 38 117 356 1090 3363 10443

Input:
11
4096
64
1000000000
15625
46656
262144
2985984
4826807
7529533
7529534
7529535

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Output: 76 10 32591 145 246 568 1860 2352 2925 2925 2925

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Output:
76

10

32591

145

246

568

1860

2352

2925

2925

2925

Output:
76

10

32591

145

246

568

1860

2352

2925

2925

2925

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925

Input:
3
5000
8000
1000000

Output:
83
105
1090

Output:
83
105
1090

Output:
83
105
1090

Output:
83

105

1090

Output:
83
105
1090

Output:
83
105
1090

Output:
83
105
1090

Output: 83 105 1090

Output:
83

105

1090

Output:
83
105
1090

Input:
17
7301384
7414875
7762392
7880599
8000000
8120601
8242408
8365427
8489664
8615125
8741816
8998912
9129329
9261000
9393931
9663597
9938375

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2883

2905

2970

2992

3014

3036

3058

3081

3103

3126

3148

3193

3216

3239

3261

3307

3353

Output: 2883 2905 2970 2992 3014 3036 3058 3081 3103 3126 3148 3193 3216 3239 3261 3307 3353

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2883

2905

2970

2992

3014

3036

3058

3081

3103

3126

3148

3193

3216

3239

3261

3307

3353

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Output:
2883
2905
2970
2992
3014
3036
3058
3081
3103
3126
3148
3193
3216
3239
3261
3307
3353

Input:
2
4096
15625

Output:
76
145

Output:
76
145

Output:
76

145

Output:
76
145

Output: 76 145

Output:
76
145

Output:
76
145

Output:
76

145

Output:
76
145

Output:
76
145

Input:
2
1000
1000000

Output:
38
1090

Output:
38
1090

Output:
38
1090

Output:
38
1090

Output:
38
1090

Output:
38

1090

Output: 38 1090

Output:
38
1090

Output:
38

1090

Output:
38
1090

Input:
13
4096
64
1000000000
15625
46656
262144
2985984
4826807
7529533
7529534
7529535
720
4095

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Output:
76

10

32591

145

246

568

1860

2352

2925

2925

2925

32

75

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Output:
76

10

32591

145

246

568

1860

2352

2925

2925

2925

32

75

Output: 76 10 32591 145 246 568 1860 2352 2925 2925 2925 32 75

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Output:
76
10
32591
145
246
568
1860
2352
2925
2925
2925
32
75

Input:
11
4096
15625
46656
117649
262144
531441
1000000
1771561
2985984
4826809
7529536

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
76

145

246

385

568

801

1090

1441

1860

2353

2926

Output: 76 145 246 385 568 801 1090 1441 1860 2353 2926

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
76

145

246

385

568

801

1090

1441

1860

2353

2926

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926

Input:
1
728999999

Output: 27869

Output: 27869

Output: 27869

Output: 27869

Output: 27869

Output: 27869

Output: 27869

Output: 27869

Input:
2
1000000
4096

Output:
1090

76

Output:
1090
76

Output:
1090
76

Output:
1090
76

Output:
1090
76

Output:
1090
76

Output:
1090
76

Output:
1090

76

Output: 1090 76

Output:
1090
76

Input:
1
531441

Output: 801

Output: 801

Output: 801

Output: 801

Output: 801

Output: 801

Output: 801

Output: 801

Input:
1
4095

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Input:
1
46142

Output: 244

Output: 244

Output: 244

Output: 244

Output: 244

Output: 244

Output: 244

Output: 244

Input:
5
125
216
2197
2744
3375

Output:
14

18

56

63

70

Output:
14
18
56
63
70

Output:
14
18
56
63
70

Output: 14 18 56 63 70

Output:
14
18
56
63
70

Output:
14
18
56
63
70

Output:
14
18
56
63
70

Output:
14

18

56

63

70

Output:
14
18
56
63
70

Output:
14
18
56
63
70

Input:
2
1000000
9025699

Output:
1090
3198

Output:
1090
3198

Output:
1090

3198

Output:
1090
3198

Output:
1090
3198

Output:
1090
3198

Output:
1090

3198

Output:
1090
3198

Output:
1090
3198

Output: 1090 3198

Input:
3
64
729
728

Output:
10
33
32

Output:
10
33
32

Output:
10
33
32

Output:
10
33
32

Output:
10
33
32

Output: 10 33 32

Output:
10
33
32

Output:
10
33
32

Output:
10

33

32

Output:
10

33

32

Input:
2
42144192
887503681

Output:
6821

30721

Output:
6821
30721

Output:
6821
30721

Output:
6821
30721

Output:
6821
30721

Output: 6821 30721

Output:
6821
30721

Output:
6821
30721

Output:
6821

30721

Output:
6821
30721

Input:
7
728999999
729000001
594823320
594823322
481890303
308915775
387420488

Output:
27869
27870
25200
25201
22707
18225
20384

Output: 27869 27870 25200 25201 22707 18225 20384

Output:
27869
27870
25200
25201
22707
18225
20384

Output:
27869
27870
25200
25201
22707
18225
20384

Output:
27869

27870

25200

25201

22707

18225

20384

Output:
27869
27870
25200
25201
22707
18225
20384

Output:
27869
27870
25200
25201
22707
18225
20384

Output:
27869
27870
25200
25201
22707
18225
20384

Output:
27869
27870
25200
25201
22707
18225
20384

Output:
27869

27870

25200

25201

22707

18225

20384

Input:
1
46655

Output: 245

Output: 245

Output: 245

Output: 245

Output: 245

Output: 245

Output: 245

Output: 245

Input:
12
64
4096
15625
46656
117649
262144
531441
1000000
1771561
2985984
4826809
7529536

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10

76

145

246

385

568

801

1090

1441

1860

2353

2926

Output: 10 76 145 246 385 568 801 1090 1441 1860 2353 2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
2926

Output:
10

76

145

246

385

568

801

1090

1441

1860

2353

2926

Input:
1
42144192

Output: 6821

Output: 6821

Output: 6821

Output: 6821

Output: 6821

Output: 6821

Output: 6821

Output: 6821

Input:
5
62
63
64
65
66

Output:
9
9
10
10
10

Output:
9
9
10
10
10

Output: 9 9 10 10 10

Output:
9
9
10
10
10

Output:
9
9
10
10
10

Output:
9

9

10

10

10

Output:
9
9
10
10
10

Output:
9
9
10
10
10

Output:
9

9

10

10

10

Output:
9
9
10
10
10

Input:
1
7529536

Output: 2926

Output: 2926

Output: 2926

Output: 2926

Output: 2926

Output: 2926

Output: 2926

Output: 2926

Input:
10
64000000
32324
4645758
148035889
382748428
33627363
36273373
75675757
9897
34536

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Output: 8380 205 2309 12673 20263 6103 6335 9101 116 212

Output:
8380

205

2309

12673

20263

6103

6335

9101

116

212

Output:
8380

205

2309

12673

20263

6103

6335

9101

116

212

Output:
8380
205
2309
12673
20263
6103
6335
9101
116
212

Input:
1
49

Output: 9

Output: 9

Output: 9

Output: 9

Output: 9

Output: 9

Output: 9

Output: 9

Input:
2
64
15625

Output:
10
145

Output:
10

145

Output:
10
145

Output:
10

145

Output:
10
145

Output:
10
145

Output:
10
145

Output:
10
145

Output:
10
145

Output: 10 145

Input:
1
64000000

Output: 8380

Output: 8380

Output: 8380

Output: 8380

Output: 8380

Output: 8380

Output: 8380

Output: 8380

Input:
5
2985983
4826807
4826808
7529533
7529534

Output:
1859
2352
2352
2925
2925

Output:
1859
2352
2352
2925
2925

Output:
1859
2352
2352
2925
2925

Output:
1859
2352
2352
2925
2925

Output:
1859

2352

2352

2925

2925

Output:
1859
2352
2352
2925
2925

Output: 1859 2352 2352 2925 2925

Output:
1859
2352
2352
2925
2925

Output:
1859
2352
2352
2925
2925

Output:
1859

2352

2352

2925

2925

Input:
3
64
15625
1000000

Output:
10
145
1090

Output:
10
145
1090

Output:
10
145
1090

Output:
10

145

1090

Output: 10 145 1090

Output:
10
145
1090

Output:
10

145

1090

Output:
10
145
1090

Output:
10
145
1090

Output:
10
145
1090

Input:
1
16777216

Output: 4336

Output: 4336

Output: 4336

Output: 4336

Output: 4336

Output: 4336

Output: 4336

Output: 4336

Input:
1
1729

Output: 50

Output: 50

Output: 50

Output: 50

Output: 50

Output: 50

Output: 50

Output: 50

Input:
13
64
4096
15625
46656
117649
262144
531441
1000000
1771561
2985984
4826809
1000000000
7529536

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output:
10

76

145

246

385

568

801

1090

1441

1860

2353

32591

2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output:
10

76

145

246

385

568

801

1090

1441

1860

2353

32591

2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output:
10
76
145
246
385
568
801
1090
1441
1860
2353
32591
2926

Output: 10 76 145 246 385 568 801 1090 1441 1860 2353 32591 2926

Input:
1
720

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Output: 32

Input:
10
728999999
729000001
594823320
594823322
481890303
308915775
387420488
191102975
148035888
113379903

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Output: 27869 27870 25200 25201 22707 18225 20384 14375 12672 11109

Output:
27869

27870

25200

25201

22707

18225

20384

14375

12672

11109

Output:
27869

27870

25200

25201

22707

18225

20384

14375

12672

11109

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Output:
27869
27870
25200
25201
22707
18225
20384
14375
12672
11109

Input:
5
62
63
64
4096
66

Output:
9
9
10
76
10

Output:
9

9

10

76

10

Output:
9

9

10

76

10

Output:
9
9
10
76
10

Output:
9
9
10
76
10

Output:
9
9
10
76
10

Output:
9
9
10
76
10

Output:
9
9
10
76
10

Output: 9 9 10 76 10

Output:
9
9
10
76
10

Input:
10
1
64
729
4096
15625
46656
117649
262144
531441
1000000

Output:
1

10

33

76

145

246

385

568

801

1090

Output:
1
10
33
76
145
246
385
568
801
1090

Output:
1
10
33
76
145
246
385
568
801
1090

Output: 1 10 33 76 145 246 385 568 801 1090

Output:
1

10

33

76

145

246

385

568

801

1090

Output:
1
10
33
76
145
246
385
568
801
1090

Output:
1
10
33
76
145
246
385
568
801
1090

Output:
1
10
33
76
145
246
385
568
801
1090

Output:
1
10
33
76
145
246
385
568
801
1090

Output:
1
10
33
76
145
246
385
568
801
1090

Input:
2
4096
720

Output: 76 32

Output:
76
32

Output:
76

32

Output:
76
32

Output:
76
32

Output:
76
32

Output:
76
32

Output:
76

32

Output:
76
32

Output:
76
32

Input:
1
15625

Output: 145

Output: 145

Output: 145

Output: 145

Output: 145

Output: 145

Output: 145

Output: 145

Input:
9
4096
15625
46656
117649
262144
531441
1000000
1771561
2985984

Output:
76
145
246
385
568
801
1090
1441
1860

Output:
76

145

246

385

568

801

1090

1441

1860

Output:
76
145
246
385
568
801
1090
1441
1860

Output: 76 145 246 385 568 801 1090 1441 1860

Output:
76
145
246
385
568
801
1090
1441
1860

Output:
76
145
246
385
568
801
1090
1441
1860

Output:
76
145
246
385
568
801
1090
1441
1860

Output:
76
145
246
385
568
801
1090
1441
1860

Output:
76

145

246

385

568

801

1090

1441

1860

Output:
76
145
246
385
568
801
1090
1441
1860

Input:
7
887503681
887503680
887503682
999887640
999887641
55240747
3566977

Output:
30721
30720
30721
32588
32589
7793
2028

Output:
30721
30720
30721
32588
32589
7793
2028

Output:
30721
30720
30721
32588
32589
7793
2028

Output:
30721

30720

30721

32588

32589

7793

2028

Output: 30721 30720 30721 32588 32589 7793 2028

Output:
30721

30720

30721

32588

32589

7793

2028

Output:
30721
30720
30721
32588
32589
7793
2028

Output:
30721
30720
30721
32588
32589
7793
2028

Output:
30721
30720
30721
32588
32589
7793
2028

Output:
30721
30720
30721
32588
32589
7793
2028

Input:
1
887503149

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Input:
8
728
1000
4095
10000
100000
1000000
10000000
100000000

Output:
32
38
75
117
356
1090
3363
10443

Output:
32
38
75
117
356
1090
3363
10443

Output:
32

38

75

117

356

1090

3363

10443

Output:
32
38
75
117
356
1090
3363
10443

Output: 32 38 75 117 356 1090 3363 10443

Output:
32
38
75
117
356
1090
3363
10443

Output:
32
38
75
117
356
1090
3363
10443

Output:
32

38

75

117

356

1090

3363

10443

Output:
32
38
75
117
356
1090
3363
10443

Output:
32
38
75
117
356
1090
3363
10443

Input:
1
991026973

Output: 32446

Output: 32446

Output: 32446

Output: 32446

Output: 32446

Output: 32446

Output: 32446

Output: 32446

Input:
6
887503681
887503680
887503682
999887640
999887641
999887642

Output:
30721
30720
30721
32588
32589
32589

Output: 30721 30720 30721 32588 32589 32589

Output:
30721
30720
30721
32588
32589
32589

Output:
30721
30720
30721
32588
32589
32589

Output:
30721

30720

30721

32588

32589

32589

Output:
30721
30720
30721
32588
32589
32589

Output:
30721
30720
30721
32588
32589
32589

Output:
30721
30720
30721
32588
32589
32589

Output:
30721
30720
30721
32588
32589
32589

Output:
30721

30720

30721

32588

32589

32589

Input:
1
4090

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Output: 75

Input:
5
125
216
343
512
729

Output:
14
18
23
28
33

Output:
14
18
23
28
33

Output:
14
18
23
28
33

Output: 14 18 23 28 33

Output:
14
18
23
28
33

Output:
14

18

23

28

33

Output:
14
18
23
28
33

Output:
14
18
23
28
33

Output:
14
18
23
28
33

Output:
14

18

23

28

33

Input:
5
720
721
722
723
724

Output:
32

32

32

32

32

Output:
32
32
32
32
32

Output:
32
32
32
32
32

Output:
32
32
32
32
32

Output:
32
32
32
32
32

Output:
32
32
32
32
32

Output: 32 32 32 32 32

Output:
32

32

32

32

32

Output:
32
32
32
32
32

Output:
32
32
32
32
32

Input:
4
64
729
728
4096

Output:
10
33
32
76

Output:
10

33

32

76

Output:
10
33
32
76

Output:
10
33
32
76

Output:
10
33
32
76

Output:
10
33
32
76

Output: 10 33 32 76

Output:
10
33
32
76

Output:
10

33

32

76

Output:
10
33
32
76

Input:
3
24389
31329
21025

Output:
180

203

167

Output:
180
203
167

Output:
180
203
167

Output:
180
203
167

Output: 180 203 167

Output:
180
203
167

Output:
180
203
167

Output:
180
203
167

Output:
180
203
167

Output:
180

203

167

Input:
9
728
1000000
35
144
4095
10000
100000
10000000
100000000

Output:
32
1090
7
15
75
117
356
3363
10443

Output: 32 1090 7 15 75 117 356 3363 10443

Output:
32
1090
7
15
75
117
356
3363
10443

Output:
32
1090
7
15
75
117
356
3363
10443

Output:
32
1090
7
15
75
117
356
3363
10443

Output:
32
1090
7
15
75
117
356
3363
10443

Output:
32

1090

7

15

75

117

356

3363

10443

Output:
32

1090

7

15

75

117

356

3363

10443

Output:
32
1090
7
15
75
117
356
3363
10443

Output:
32
1090
7
15
75
117
356
3363
10443

Input:
2
15625
4096

Output:
145
76

Output:
145
76

Output:
145
76

Output:
145

76

Output:
145
76

Output:
145
76

Output:
145
76

Output:
145

76

Output:
145
76

Output: 145 76

Input:
1
262144

Output: 568

Output: 568

Output: 568

Output: 568

Output: 568

Output: 568

Output: 568

Output: 568

Input:
1
1771561

Output: 1441

Output: 1441

Output: 1441

Output: 1441

Output: 1441

Output: 1441

Output: 1441

Output: 1441

Input:
1
238144

Output: 542

Output: 542

Output: 542

Output: 542

Output: 542

Output: 542

Output: 542

Output: 542

Input:
1
11390625

Output: 3585

Output: 3585

Output: 3585

Output: 3585

Output: 3585

Output: 3585

Output: 3585

Output: 3585

Input:
1
24137569

Output: 5185

Output: 5185

Output: 5185

Output: 5185

Output: 5185

Output: 5185

Output: 5185

Output: 5185

Input:
1
34012224

Output: 6138

Output: 6138

Output: 6138

Output: 6138

Output: 6138

Output: 6138

Output: 6138

Output: 6138

Input:
1
308915776

Output: 18226

Output: 18226

Output: 18226

Output: 18226

Output: 18226

Output: 18226

Output: 18226

Output: 18226

Input:
1
387420489

Output: 20385

Output: 20385

Output: 20385

Output: 20385

Output: 20385

Output: 20385

Output: 20385

Output: 20385

Input:
4
4096
15625
117649
262144

Output:
76
145
385
568

Output: 76 145 385 568

Output:
76
145
385
568

Output:
76
145
385
568

Output:
76

145

385

568

Output:
76

145

385

568

Output:
76
145
385
568

Output:
76
145
385
568

Output:
76
145
385
568

Output:
76
145
385
568

Input:
1
481890304

Output: 22708

Output: 22708

Output: 22708

Output: 22708

Output: 22708

Output: 22708

Output: 22708

Output: 22708

Input:
4
481890304
594823321
729000000
887503681

Output:
22708
25201
27870
30721

Output:
22708
25201
27870
30721

Output:
22708

25201

27870

30721

Output:
22708
25201
27870
30721

Output: 22708 25201 27870 30721

Output:
22708
25201
27870
30721

Output:
22708
25201
27870
30721

Output:
22708

25201

27870

30721

Output:
22708
25201
27870
30721

Output:
22708
25201
27870
30721

Input:
7
244140625
308915776
387420489
481890304
594823321
729000000
887503681

Output:
16225

18226

20385

22708

25201

27870

30721

Output:
16225
18226
20385
22708
25201
27870
30721

Output:
16225
18226
20385
22708
25201
27870
30721

Output:
16225
18226
20385
22708
25201
27870
30721

Output:
16225
18226
20385
22708
25201
27870
30721

Output: 16225 18226 20385 22708 25201 27870 30721

Output:
16225
18226
20385
22708
25201
27870
30721

Output:
16225
18226
20385
22708
25201
27870
30721

Output:
16225

18226

20385

22708

25201

27870

30721

Output:
16225
18226
20385
22708
25201
27870
30721

Input:
20
117649
262144
531441
1000000
1771561
7529536
11390625
24137569
34012224
85766121
113379904
148035889
191102976
244140625
308915776
387420489
481890304
594823321
729000000
887503681

Output:
385

568

801

1090

1441

2926

3585

5185

6138

9681

11110

12673

14376

16225

18226

20385

22708

25201

27870

30721

Output: 385 568 801 1090 1441 2926 3585 5185 6138 9681 11110 12673 14376 16225 18226 20385 22708 25201 27870 30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Output:
385

568

801

1090

1441

2926

3585

5185

6138

9681

11110

12673

14376

16225

18226

20385

22708

25201

27870

30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Output:
385
568
801
1090
1441
2926
3585
5185
6138
9681
11110
12673
14376
16225
18226
20385
22708
25201
27870
30721

Input:
5
49
50
675
676
677

Output:
9
9
31
32
32

Output:
9
9
31
32
32

Output:
9
9
31
32
32

Output:
9
9
31
32
32

Output:
9
9
31
32
32

Output:
9
9
31
32
32

Output:
9

9

31

32

32

Output:
9

9

31

32

32

Output: 9 9 31 32 32

Output:
9
9
31
32
32

Input:
5
64000000
85766121
113379904
148035889
8000

Output:
8380

9681

11110

12673

105

Output:
8380
9681
11110
12673
105

Output:
8380
9681
11110
12673
105

Output:
8380

9681

11110

12673

105

Output:
8380
9681
11110
12673
105

Output:
8380
9681
11110
12673
105

Output: 8380 9681 11110 12673 105

Output:
8380
9681
11110
12673
105

Output:
8380
9681
11110
12673
105

Output:
8380
9681
11110
12673
105

Input:
1
887483586

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Output: 30720

Input:
20
887503680
887503679
887503678
887503677
887503676
887503675
887503674
887503673
887503672
887503671
887503670
887503669
887503668
887503667
887503666
887503665
887503664
887503663
887503662
887503661

Output: 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720 30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

Output:
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720
30720

Output:
30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

30720

Input:
5
8000
64000000
85766121
113379904
148035889

Output:
105

8380

9681

11110

12673

Output:
105
8380
9681
11110
12673

Output:
105
8380
9681
11110
12673

Output:
105
8380
9681
11110
12673

Output:
105
8380
9681
11110
12673

Output:
105
8380
9681
11110
12673

Output: 105 8380 9681 11110 12673

Output:
105
8380
9681
11110
12673

Output:
105
8380
9681
11110
12673

Output:
105

8380

9681

11110

12673

Input:
1
134217728

Output: 12075

Output: 12075

Output: 12075

Output: 12075

Output: 12075

Output: 12075

Output: 12075

Output: 12075

Input:
2
49
676

Output:
9

32

Output:
9
32

Output: 9 32

Output:
9

32

Output:
9
32

Output:
9
32

Output:
9
32

Output:
9
32

Output:
9
32

Output:
9
32

Input:
3
887503681
887503680
887503682

Output:
30721
30720
30721

Output:
30721
30720
30721

Output:
30721
30720
30721

Output:
30721
30720
30721

Output: 30721 30720 30721

Output:
30721
30720
30721

Output:
30721
30720
30721

Output:
30721

30720

30721

Output:
30721

30720

30721

Output:
30721
30720
30721

Input:
2
15625
46656

Output:
145
246

Output:
145
246

Output:
145
246

Output:
145
246

Output:
145
246

Output:
145
246

Output: 145 246

Output:
145

246

Output:
145
246

Output:
145

246

Input:
20
4096
15625
46656
117649
262144
531441
1000000
1771561
2985984
4826809
7529536
11390625
16777216
24137569
34012224
47045881
64000000
85766121
113379904
148035889

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output:
76

145

246

385

568

801

1090

1441

1860

2353

2926

3585

4336

5185

6138

7201

8380

9681

11110

12673

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output:
76

145

246

385

568

801

1090

1441

1860

2353

2926

3585

4336

5185

6138

7201

8380

9681

11110

12673

Output:
76
145
246
385
568
801
1090
1441
1860
2353
2926
3585
4336
5185
6138
7201
8380
9681
11110
12673

Output: 76 145 246 385 568 801 1090 1441 1860 2353 2926 3585 4336 5185 6138 7201 8380 9681 11110 12673

Input:
3
15625
97336
195112

Output:
145
351
492

Output:
145
351
492

Output: 145 351 492

Output:
145
351
492

Output:
145
351
492

Output:
145
351
492

Output:
145
351
492

Output:
145

351

492

Output:
145
351
492

Output:
145

351

492

Input:
20
125
216
343
512
1000
1331
1728
2197
2744
3375
4913
5832
6859
8000
9261
10648
12167
13824
17576
19683

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Output: 14 18 23 28 38 44 50 56 63 70 83 90 97 105 113 121 129 137 153 162

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Output:
14

18

23

28

38

44

50

56

63

70

83

90

97

105

113

121

129

137

153

162

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Output:
14

18

23

28

38

44

50

56

63

70

83

90

97

105

113

121

129

137

153

162

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Output:
14
18
23
28
38
44
50
56
63
70
83
90
97
105
113
121
129
137
153
162

Input:
1
97336

Output: 351

Output: 351

Output: 351

Output: 351

Output: 351

Output: 351

Output: 351

Output: 351

Input:
20
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883
999950883

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output: 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589 32589

Output:
32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output:
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589
32589

Output:
32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589

32589


You are given an integer array $$$a_0, a_1, \dots, a_{n - 1}$$$, and an integer $$$k$$$. You perform the following code with it:long long ans = 0; // create a 64-bit signed variable which is initially equal to 0for(int i = 1; i <= k; i++){  int idx = rnd.next(0, n - 1); // generate a random integer between 0 and n - 1, both inclusive                                // each integer from 0 to n - 1 has the same probability of being chosen  ans += a[idx];  a[idx] -= (a[idx] % i);}Your task is to calculate the expected value of the variable ans after performing this code.Note that the input is generated according to special rules (see the input format section).

NoteThe array in the first example test is $$$[10, 35, 22]$$$. In the second example, it is $$$[15363, 1418543]$$$.

The only line contains six integers $$$n$$$, $$$a_0$$$, $$$x$$$, $$$y$$$, $$$k$$$ and $$$M$$$ ($$$1 \le n \le 10^7$$$; $$$1 \le a_0, x, y < M \le 998244353$$$; $$$1 \le k \le 17$$$). The array $$$a$$$ in the input is constructed as follows:   $$$a_0$$$ is given in the input;  for every $$$i$$$ from $$$1$$$ to $$$n - 1$$$, the value of $$$a_i$$$ can be calculated as $$$a_i = (a_{i - 1} \cdot x + y) \bmod M$$$.

Let the expected value of the variable ans after performing the code be $$$E$$$. It can be shown that $$$E \cdot n^k$$$ is an integer. You have to output this integer modulo $$$998244353$$$.

Input: 3 10 3 5 13 88

Output: 382842030

Output: 382842030

Output: 382842030

Output: 382842030

Input: 2 15363 270880 34698 17 2357023

Output: 319392398

Output: 319392398

Output: 319392398

Output: 319392398

Input: 1 235 125 236 1 2356723

Output: 235

Output: 235

Output: 235

Output: 235

Input: 1 235 125 236 2 2356723

Output: 470

Output: 470

Output: 470

Output: 470

Input: 2 235 125 236 2 2356723

Output: 119384

Output: 119384

Output: 119384

Output: 119384

Input: 2 235 125 236 1 2356723

Output: 29846

Output: 29846

Output: 29846

Output: 29846

Input: 10000000 235 125 236 2 2356723

Output: 990723407

Output: 990723407

Output: 990723407

Output: 990723407

Input: 10000000 42 13 37 17 998244353

Output: 364558986

Output: 364558986

Output: 364558986

Output: 364558986

Input: 10000000 42 13 37 17 900000011

Output: 107238563

Output: 107238563

Output: 107238563

Output: 107238563

Input: 10000000 2 2 2 17 998244353

Output: 254345819

Output: 254345819

Output: 254345819

Output: 254345819

Input: 10000000 4 2 277 17 998244353

Output: 92468755

Output: 92468755

Output: 92468755

Output: 92468755

Input: 10000000 4 2 3 17 998244353

Output: 138333410

Output: 138333410

Output: 138333410

Output: 138333410

Input: 1 998244352 1 1 1 998244353

Output: 998244352

Output: 998244352

Output: 998244352

Output: 998244352