[
 {
  "id": "APPS-3854",
  "question": "Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is c_{i}. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya.\n\nLooking at her coins, a question came to her mind: after giving the coins to Arya, what values does Arya can make with them? She is jealous and she doesn't want Arya to make a lot of values. So she wants to know all the values x, such that Arya will be able to make x using some subset of coins with the sum k.\n\nFormally, Pari wants to know the values x such that there exists a subset of coins with the sum k such that some subset of this subset has the sum x, i.e. there is exists some way to pay for the chocolate, such that Arya will be able to make the sum x using these coins.\n\n\n-----Input-----\n\nThe first line contains two integers n and k (1  ≤  n, k  ≤  500) — the number of coins and the price of the chocolate, respectively.\n\nNext line will contain n integers c_1, c_2, ..., c_{n} (1 ≤ c_{i} ≤ 500) — the values of Pari's coins.\n\nIt's guaranteed that one can make value k using these coins.\n\n\n-----Output-----\n\nFirst line of the output must contain a single integer q— the number of suitable values x. Then print q integers in ascending order — the values that Arya can make for some subset of coins of Pari that pays for the chocolate.\n\n\n-----Examples-----\nInput\n6 18\n5 6 1 10 12 2\n\nOutput\n16\n0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 \n\nInput\n3 50\n25 25 50\n\nOutput\n3\n0 25 50",
  "inputs": [
   "6 18\n5 6 1 10 12 2\n",
   "3 50\n25 25 50\n",
   "1 79\n79\n",
   "1 114\n114\n",
   "5 1\n1 500 205 6 355\n",
   "8 42\n7 24 22 25 31 12 17 26\n",
   "8 91\n74 25 66 50 62 30 50 50\n",
   "8 15\n13 3 5 5 6 14 5 5\n",
   "8 39\n38 17 25 33 7 29 15 22\n",
   "15 185\n69 61 185 127 169 42 140 93 12 115 36 46 19 80 123\n",
   "15 109\n92 60 14 9 22 99 17 22 82 28 105 98 109 20 32\n",
   "10 147\n15 76 48 111 39 111 145 16 34 68\n",
   "10 67\n58 39 56 7 51 47 20 26 24 54\n",
   "10 195\n157 4 183 125 63 121 113 3 145 103\n",
   "14 176\n66 109 148 141 65 52 147 65 171 11 157 60 151 19\n",
   "14 54\n54 39 2 16 17 18 41 22 25 30 54 4 27 2\n",
   "14 24\n18 16 15 24 18 19 19 8 8 2 4 9 18 9\n",
   "5 182\n134 18 48 91 25\n",
   "15 182\n63 17 134 113 18 48 112 175 91 25 176 55 78 177 175\n",
   "5 6\n2 71 7 27 6\n",
   "5 34\n28 32 91 6 70\n",
   "10 58\n57 2 18 35 3 35 38 7 38 3\n",
   "10 10\n7 4 6 2 9 6 8 8 10 10\n",
   "10 38\n16 21 7 12 20 37 34 7 6 20\n",
   "10 58\n30 51 7 29 25 2 44 28 49 45\n"
  ],
  "outputs": [
   "16\n0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 \n",
   "3\n0 25 50 \n",
   "2\n0 79 \n",
   "2\n0 114 \n",
   "2\n0 1 \n",
   "4\n0 17 25 42 \n",
   "4\n0 25 66 91 \n",
   "4\n0 5 10 15 \n",
   "8\n0 7 15 17 22 24 32 39 \n",
   "34\n0 12 19 31 36 42 46 55 58 61 69 73 78 80 82 88 92 93 97 103 105 107 112 116 124 127 130 139 143 149 154 166 173 185 \n",
   "28\n0 17 20 22 28 32 37 39 42 44 45 48 49 50 59 60 61 64 65 67 70 72 77 81 87 89 92 109 \n",
   "16\n0 15 16 31 48 63 64 68 79 83 84 99 116 131 132 147 \n",
   "4\n0 20 47 67 \n",
   "16\n0 3 4 7 63 66 67 70 125 128 129 132 188 191 192 195 \n",
   "4\n0 19 157 176 \n",
   "23\n0 2 4 6 8 16 18 20 22 24 25 27 29 30 32 34 36 38 46 48 50 52 54 \n",
   "14\n0 2 4 6 8 9 11 13 15 16 18 20 22 24 \n",
   "15\n0 18 25 43 48 66 73 91 109 116 134 139 157 164 182 \n",
   "15\n0 18 25 43 48 66 73 91 109 116 134 139 157 164 182 \n",
   "2\n0 6 \n",
   "4\n0 6 28 34 \n",
   "16\n0 2 3 5 18 20 21 23 35 37 38 40 53 55 56 58 \n",
   "6\n0 2 4 6 8 10 \n",
   "8\n0 6 12 18 20 26 32 38 \n",
   "10\n0 2 7 9 28 30 49 51 56 58 \n"
  ]
 },
 {
  "id": "APPS-3773",
  "question": "Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i.\nStarting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation:\n - Choose a pile. If the i-th pile is selected and there are X stones left in the pile, remove some number of stones between 1 and floor(X/K_i) (inclusive) from the pile.\nThe player who first becomes unable to perform the operation loses the game. Assuming that both players play optimally, determine the winner of the game.\nHere, floor(x) represents the largest integer not greater than x.\n\n-----Constraints-----\n - 1 \\leq N \\leq 200\n - 1 \\leq A_i,K_i \\leq 10^9\n - All input values are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nA_1 K_1\n:\nA_N K_N\n\n-----Output-----\nIf Takahashi will win, print Takahashi; if Aoki will win, print Aoki.\n\n-----Sample Input-----\n2\n5 2\n3 3\n\n-----Sample Output-----\nAoki\n\nInitially, from the first pile at most floor(5/2)=2 stones can be removed at a time, and from the second pile at most floor(3/3)=1 stone can be removed at a time.\n - If Takahashi first takes two stones from the first pile, from the first pile at most floor(3/2)=1 stone can now be removed at a time, and from the second pile at most floor(3/3)=1 stone can be removed at a time.\n - Then, if Aoki takes one stone from the second pile, from the first pile at most floor(3/2)=1 stone can be removed at a time, and from the second pile no more stones can be removed (since floor(2/3)=0).\n - Then, if Takahashi takes one stone from the first pile, from the first pile at most floor(2/2)=1 stone can now be removed at a time, and from the second pile no more stones can be removed.\n - Then, if Aoki takes one stone from the first pile, from the first pile at most floor(1/2)=0 stones can now be removed at a time, and from the second pile no more stones can be removed.\nNo more operation can be performed, thus Aoki wins. If Takahashi plays differently, Aoki can also win by play accordingly.",
  "inputs": [
   "2\n5 2\n3 3\n",
   "3\n3 2\n4 3\n5 1\n",
   "3\n28 3\n16 4\n19 2\n",
   "4\n3141 59\n26535 897\n93 23\n8462 64\n",
   "199\n675026050 9\n27416216 9\n74635109 3\n744438547 8\n990621544 9\n93656461 10\n423452939 5\n882573696 5\n568799164 5\n246311286 9\n730678092 9\n477660175 3\n783628407 1\n792825591 3\n787525242 9\n182974900 4\n594486132 2\n14071970 4\n125813751 3\n907846406 4\n241647564 2\n356597228 10\n101868697 3\n55756893 4\n292220547 4\n715245338 10\n80071281 10\n967277095 3\n22723314 9\n943517075 1\n280993514 8\n619899786 6\n625700785 10\n398615495 6\n508931171 9\n951453786 7\n384538980 6\n358761000 10\n655277118 4\n25038388 6\n683337995 2\n6349763 2\n697809558 8\n551412194 3\n113965582 1\n64685423 2\n982428057 4\n255384965 4\n937858122 9\n159484857 1\n67670293 1\n825793826 10\n69788196 7\n565659751 6\n357226401 4\n21825297 10\n943517075 1\n768527971 8\n854956923 9\n324080133 8\n968912253 1\n911201625 4\n22479300 6\n996557909 10\n96612721 10\n958332895 8\n279191751 7\n821218801 4\n97283422 10\n519303810 3\n23426703 10\n666638184 4\n285869145 4\n52424971 2\n983227874 6\n252863645 4\n223058556 4\n694491384 1\n902848861 9\n473979547 3\n496074291 10\n621030109 6\n326955073 7\n343113681 5\n462520687 3\n964075734 5\n971283760 6\n597715017 6\n615455271 4\n169034152 5\n158398860 1\n494571695 1\n334296536 2\n569752303 7\n636441103 2\n256286433 2\n761418519 5\n925733865 4\n98850074 4\n380991922 6\n642299509 3\n276463464 2\n581162314 1\n638463374 1\n677247093 9\n724754072 7\n60034250 7\n512711429 2\n866038195 7\n788588284 10\n400540612 2\n358865470 1\n6511927 7\n721546052 4\n113220074 1\n637630186 6\n16322495 3\n756409746 8\n362554319 9\n502881399 7\n126006911 10\n954550687 2\n631548969 1\n160614424 1\n182417278 1\n14478392 2\n201000167 8\n706552971 1\n651592018 3\n631957081 6\n131474455 9\n942689 5\n690814591 8\n671916106 6\n442972201 9\n7580886 5\n757946837 3\n587653733 1\n48375532 3\n984390414 7\n392993925 1\n988383918 7\n407765682 5\n636441103 2\n35886993 3\n976173645 8\n508556155 4\n625289844 4\n547313696 3\n223058556 4\n298506844 6\n950750294 6\n61103187 4\n745157446 5\n534974101 4\n284404212 3\n633754040 8\n213078562 6\n52703599 4\n16843986 6\n506613896 2\n988588016 9\n385806266 2\n798096966 5\n655863339 7443\n171199126 5\n697642757 8\n113951051 4\n4394354 10\n15513495 10\n963642908 6\n745782971 2\n43951962 10\n26449993 2\n903627293 5\n745678687 2\n996052651 6\n44648878 3\n938101756 2\n70017233 3\n782009476 6\n419366559 4\n563361442 7\n877957287 4\n30901452 3\n175927165 9\n681001345 8\n35023686 6\n909300774 5\n516923292 7\n843640231 4\n661777545 9\n994568590 8\n844706915 10\n206171848 2\n412174014 4\n46174063 6\n634247412 6\n73979021 1795\n",
   "198\n609136623 5\n57022143 8\n510874601 10\n236893050 2\n84270306 5\n735457148 1\n234999909 1\n66312555 6\n110594271 1\n140493472 3\n298298287 8\n676417511 7\n660949055 8\n618269120 9\n769512711 9\n1764500 1\n471875010 9\n1979144 5\n677853653 3\n160994660 5\n71173450 2\n400696728 9\n340835908 8\n369012703 9\n538540601 3\n14045473 8\n696638240 5\n246312015 6\n878991322 8\n689728033 6\n225291570 3\n238328206 1\n54980252 5\n477147293 2\n317276967 7\n615795312 7\n804649737 9\n196526462 1\n614608449 5\n103105903 3\n397792136 4\n232760352 6\n403790199 6\n144623283 6\n726936854 10\n531998768 2\n461848476 4\n988303065 2\n538514024 6\n556842199 3\n59680711 3\n549652142 5\n17701231 7\n613611948 5\n95166688 3\n995553829 9\n489736971 5\n790543805 9\n173472982 9\n617431917 9\n432769253 10\n852155277 7\n255582724 2\n738903070 8\n345558953 10\n621441908 10\n845341216 7\n233653118 4\n251513126 5\n131960640 9\n146487183 6\n655863339 7443\n533486496 2\n205525825 5\n13465481 2\n854185644 10\n91831820 4\n791849595 6\n72110363 8\n39115441 1\n964329925 10\n583865379 10\n591304566 3\n181168690 7\n846600661 4\n592128371 5\n169353650 8\n461666717 9\n398341006 7\n85092881 9\n781859723 4\n71649997 8\n72317813 5\n952282817 3\n60943375 5\n197059421 5\n463396275 8\n626806746 8\n421031258 2\n331988589 3\n103256074 7\n394679452 6\n242178020 1\n284924978 5\n768440985 8\n889380281 6\n522478528 5\n66312555 6\n991896323 7\n628041125 2\n526843382 10\n178519294 5\n107526055 2\n787733251 9\n91831820 4\n951983519 1\n363916228 5\n471875010 9\n46168305 10\n592646280 6\n679457612 6\n20950985 7\n282359149 1\n945285678 2\n445860590 3\n867186447 3\n900994801 3\n880361755 9\n939969171 6\n624777805 10\n59422284 3\n234387008 8\n420857037 2\n560579448 6\n175146490 2\n593336874 9\n17776007 8\n324237245 6\n529461198 2\n104857469 9\n297196524 1\n214002226 5\n14515298 5\n54452658 4\n321468695 9\n70460616 8\n257096269 9\n572040578 8\n411302485 3\n339531323 1\n217071289 7\n21998458 8\n976615897 6\n918886557 4\n21704785 8\n774107588 3\n591909808 4\n228309825 9\n670275015 4\n371868170 9\n593402231 2\n555717719 4\n789089204 1\n608471800 7\n751542449 2\n443688330 8\n381498098 8\n310203363 9\n572277810 8\n579656358 3\n775565745 5\n51085656 5\n428670919 4\n210310738 3\n55881135 1\n389555384 7\n480459607 9\n13953724 4\n317547072 5\n94915900 4\n92725688 9\n776344154 8\n982864266 2\n852271328 2\n112955151 3\n106246171 2\n657779569 10\n987498326 1\n218668524 5\n967017787 9\n845681177 9\n711087623 2\n404363202 10\n795510697 5\n58012143 3\n300827810 3\n19283380 8\n492233194 7\n",
   "200\n30145812 28\n338684140 16\n848673794 24\n842046743 17\n982512490 34\n842541562 46\n320997610 5\n335754944 39\n206930507 4\n949105940 23\n381087794 36\n476936217 78\n584594559 13\n63285922 58\n553055064 21\n837461248 21\n21460348 82\n283571925 60\n388127970 72\n619476673 76\n30157574 70\n102710585 3\n81677101 40\n308067584 77\n655541366 84\n220145685 53\n684241227 84\n141233675 56\n946713849 85\n971521957 76\n268563541 40\n571487137 55\n412580503 61\n858703083 49\n428376162 60\n496763064 6361\n632697448 78\n534014747 27\n217133810 28\n330247172 44\n610741755 26\n61154041 60\n69451672 48\n480228031 40\n824727729 47\n251813467 33\n469631421 50\n988617718 10\n402057255 5\n306822114 31\n139344454 43\n716642687 10\n386981088 22\n729890618 42\n657075613 70\n632697448 78\n24132577 54\n67763923 52\n213242592 14\n61811666 95\n657280544 30\n468932014 47\n398536794 44\n475994531 24\n181978347 75\n903669864 24\n166901290 15\n557312008 66\n863113672 78\n382328218 67\n136515391 19\n410003021 60\n328774350 67\n629635177 14\n234145831 55\n318441051 13\n905623583 74\n382328218 67\n767164858 61\n594640372 76\n161369802 17\n668732949 16\n682127460 69\n206601624 16\n388316184 32\n35307132 63\n615505452 45\n987205267 65\n196550554 60\n28458796 49\n611474608 54\n16884486 36\n681999173 39\n191633659 77\n977823226 59\n20794812 43\n375078800 86\n761961498 75\n69301006 13\n849685795 4\n25928912 91\n445604234 40\n955782523 42\n423300057 23\n548912365 69\n818877992 17\n962082452 55\n395697616 65\n919762992 88\n478840396 91\n119628364 48\n285999730 45\n322137646 80\n157193157 26051\n294156345 43\n128484881 3\n675927431 6\n898482432 54\n547457745 91\n525465664 40\n234201898 51\n359967830 92\n89873610 61\n601351436 27\n715786535 34\n748235242 31\n141648621 20\n935829420 1\n883625750 44\n16366997 10\n780603729 67\n878948200 34\n766597536 96\n498740271 100\n844706304 57\n820281660 15\n836732982 25\n42945379 25\n832929552 77\n905990393 17\n812177476 60\n712569337 18\n430888375 48\n523969409 31\n634709603 62\n606323736 8\n804288870 40\n978716233 82\n461625068 28\n965241438 7\n884847544 85\n514926323 34\n983322014 44\n113908068 9\n577375859 2\n995940804 76\n707975273 57\n251349687 82\n763840189 85\n780868604 19\n295381958 83\n181978347 75\n555438079 80\n526784081 97\n62404594 4\n554901901 91\n805744170 42\n591547052 38\n248914913 38\n615738186 91\n388450364 74\n852742342 66\n992313712 1\n685137314 73\n605486948 42\n567696422 47\n960291846 97\n84674254 73\n622813971 43\n339646744 34\n991322871 74\n753627448 35\n101268808 12\n211754341 11\n865072372 35\n322730074 10\n129767534 20\n334927420 61\n787606418 7\n494600754 87\n89197313 59\n830234385 59\n824695977 36\n223452406 87\n946004095 60\n521551946 49\n638423993 47\n346690835 70\n60940325 53\n30679679 376\n",
   "199\n699970005 10\n315945383 17\n650761537 15\n146034700 63\n504691636 40\n992313712 1\n822526486 47\n437135469 11\n791519401 21\n464855977 42\n190032435 97\n927587191 10\n527982527 65\n993172839 30\n157383194 28\n215913867 59\n572641068 45\n419474912 9\n192129505 23\n165472475 85\n15300099 12\n287807236 73\n946896234 87\n635732807 3\n460553441 66\n404291320 31\n99606446 4\n760497514 52\n316359507 54\n680106766 25\n400700869 53\n594133585 84\n800111031 7\n146539256 16\n519331273 46\n970306043 88\n296691267 13\n943200084 70\n359653286 5\n76534335 20\n55033609 58\n964397506 80\n781107519 60\n370484607 14\n100409650 32\n856655014 30\n903603913 39\n440686753 97\n678747766 6\n855952854 31\n762285510 4\n746887756 22\n219320228 62\n179634971 46\n731183326 81\n185183481 72\n820281660 15\n183270676 22\n336867786 81\n182140331 95\n779214542 43\n901151016 19\n20326573 73\n745121818 98\n823613254 79\n521656454 44\n209126136 64\n687499894 69\n687888854 16\n903137161 5\n252066819 70\n115916136 55\n239252626 22\n682470566 33\n14149090 6\n733288261 81\n422083929 83\n594495450 89\n310558778 99\n679113992 52\n703064093 9\n859003575 73\n995202527 9\n827206285 50\n891351206 100\n275422120 57\n699269430 34\n611917591 29\n926807477 47\n59747593 30\n235795592 40\n506494327 40\n738629848 100\n632697448 78\n617794752 99\n900392737 86\n766262136 43\n356922241 57\n825480597 63\n261334629 71\n717734524 94\n549594935 79\n134737215 36\n754941102 24\n897919857 842\n548751541 8\n886190238 16\n104103102 68\n265163110 52\n29937424 96\n606843672 60\n66993317 48\n274725003 91\n527099077 24\n719456711 94\n333530250 14\n277920679 63\n548998014 31\n432106645 54\n36652716 19\n362107267 10\n657038228 68\n285847370 68\n740109746 84\n515617620 76\n753056676 92\n807178059 87\n429804494 32\n141557052 33\n348320501 17\n656989779 3\n131877446 31\n901768467 36\n851506123 29\n18961331 96\n158845458 22\n861153642 14\n825283655 53\n447261961 51\n12834283 30\n774417261 19\n92940894 15\n375078800 86\n412629368 72\n722177985 17\n322357045 50\n840464010 54\n689275736 94\n236224744 27\n872749490 52\n31719076 74\n586278756 99\n956073087 74\n603043184 24\n317594618 100\n185838416 16\n271203932 63\n620260832 1\n498740271 100\n361808064 52\n79202212 75\n41447740 39\n902862274 69\n55033609 58\n865700323 32\n978203902 5\n693874184 21\n393870114 91\n57592176 1\n245944812 12\n816906477 31\n281872748 586\n679113992 52\n714795938 45\n702716148 33\n946961806 64\n44460471 45\n699650852 80\n409905179 89\n31876929 88\n291638358 35\n569494112 15\n710574313 87\n30180962 98\n712689460 95\n106182358 64\n827206285 50\n183270676 22\n621357356 32\n819402808 24\n37594959 45\n307174689 42\n151873843 30\n51145331 62\n490012651 9\n657549751 76\n850782283 57\n518207887 43\n905926020 90\n",
   "198\n459743289 775\n882524329 278\n865166951 684\n457449553 561\n494659956 124\n371378053 57\n317268367 209\n899119481 723\n973984416 309\n165436578 635\n244954806 172\n930004935 435\n976601886 836\n32636993 3873\n129521324 916\n774798626 5408\n297478040 200\n834277519 958\n359774726 261\n115045069 11116\n221483739 498\n736515600 589\n39435670 603\n473688525 362\n466523627 342\n168306184 491\n816236728 275\n167358761 645\n600439630 722\n238393352 895\n249627945 633\n125477423 720\n115681525 539\n29054026 182\n385456419 164\n343872140 653\n973111659 688\n256918666 314\n602884743 699\n16660650 115\n781257363 735\n720145679 932\n230648725 923\n498272949 79628\n587981131 926\n834086860 675\n419344474 124\n64561340 43\n479397441 6\n477551865 650\n53515127 272\n650877849 923\n928687470 920\n255961631 899\n726444193 542\n732601670 749\n531876882 414\n378091746 631\n521500309 306\n540960173 641\n48574346 877\n324228532 606\n748209524 463\n571587078 583\n82709762 230\n225565310 468\n151463048 341\n780150454 171\n751784713 67226\n44007084 192\n41196981 964\n766081415 972\n245652615 616\n370839137 57\n69184110 781\n350768461 592\n159685817 245\n512403844 134\n374829722 689\n33297739 314\n102421233 7954\n798700999 24\n381897145 661\n775402768 734\n349049457 630\n177657066 723\n243376342 827\n605055822 75\n786924253 51\n850417113 840\n521393323 215\n244260975 609\n806530768 983\n177053549 97\n891851955 248\n424065421 29\n761450352 5701\n87285862 567\n34802520 398\n16044275 615\n244263076 32\n855064535 98\n283053719 61\n471249356 102\n925037810 999\n250453703 144\n740353904 565\n995032741 455\n804007933 330\n446922464 990\n690422181 392\n342283093 614\n810019477 500\n961140853 381\n254034762 8732\n587171000 15\n208312482 678\n951766423 324\n164632087 574\n58281207 860\n675883029 74\n586541766 80\n320624673 745\n630307573 679\n709739531 882\n634439100 618\n477305384 470\n410838266 859\n175584800 871\n535901436 246\n68305067 184\n943895008 469\n83269165 898\n307365310 918\n747397739 440\n308539062 897\n743895603 422\n941266599 365\n869731363 633\n319033863 40\n999533314 811\n282024686 529\n462686862 327\n328123648 117\n589340262 195\n571063801 630\n413171677 901\n948515317 902\n177846051 240\n491122116 358\n999517225 897\n52634131 126\n380078729 135\n767595783 165\n814215145 121\n992270017 946\n724147597 33\n769723393 297\n832625510 8\n539347433 546\n358506384 328\n590431710 975\n390341369 340\n687929000 687\n865740137 109\n200226503 347\n52221699 461\n787470737 558\n7542019 608\n958351732 770\n107209799 605\n872156539 26\n941172386 394\n300559591 576\n324940397 889\n445496214 964\n924983860 725\n35886217 170\n45930403 838\n775168227 863\n770922769 152\n439308184 6\n580261280 982\n855340440 17\n672370812 648\n58216603 613\n99840606 379\n983784889 61\n620622880 574\n78931175 671\n856076766 344\n377627548 408\n445079251 9946\n284360821 399\n411350015 679\n85865754 41\n248317331 486\n421553154 3320\n",
   "200\n342728439 6\n379754735 968\n361006253 386\n77590218 855\n47542148 87\n819481928 60\n961240541 982\n135938826 66\n876950879 939\n974505509 122\n437812111 597\n980708179 274\n838560892 535\n163541739 620\n377627548 408\n63367405 114\n676319072 472\n595093233 429\n595481242 6877\n597611159 58\n16188054 989\n286113380 252\n282239146 859\n856893916 819\n894317455 527\n28152186 474\n310673184 464\n199275774 953\n746843816 633\n365059482 383\n474700156 675\n85455126 385\n99420594 667\n863723779 933\n71940338 146\n221483739 498\n902570108 321\n859664002 541\n689543133 878\n790878913 363\n890336511 737\n106933250 35\n751283263 267\n775470613 559\n433496150 127\n790315792 385\n592978130 791\n717838192 443\n583263035 988\n211823161 417\n957631219 577\n458822538 133\n477881993 235\n351505116 263\n122534830 246\n612074935 524\n773260150 254\n722446086 167\n804007933 330\n565799576 336\n440153498 591\n851948358 687\n552027051 247\n401624024 45476\n749607110 488\n478458417 354\n919660983 371\n166821133 334\n81630799 705\n247680528 945\n29279085 418\n857248967 859\n554002084 72\n821448387 858\n514753845 204\n369315348 419\n779507860 375\n715995466 462\n747397739 440\n41681104 440\n512403844 134\n720225428 556\n701426017 777\n78889440 413\n525590465 306\n91656857 932\n940174753 125\n851954001 7\n745556191 904\n285165158 838\n896930146 493\n467514645 7\n865541388 323\n370839137 57\n921905141 442\n459281210 792\n562795928 187\n226196594 300\n179543761 706\n531015303 70\n692517003 931\n916968061 947\n722347723 700\n917323805 298\n459994960 57\n549129463 43\n726216911 123\n394691656 63090\n229924550 353\n188804362 117\n213454536 66\n762953066 417\n742248775 522\n622189070 705\n495794655 75\n679101797 692\n377313750 263\n382632812 321\n448625613 911\n360768740 26\n819494616 14948\n145594049 461\n848762944 840\n808175519 9\n837426254 845\n105090523 449\n310148175 229\n520922942 781\n301681441 10\n670776820 774\n91022670 31\n796945887 66\n198057216 56\n214358689 386\n722860144 878\n527202703 116\n403756171 253\n704065590 3803\n272683091 464\n369423430 348\n137577928 808\n476517511 251\n335941757 368\n968404583 243\n507782906 814\n206658169 748\n87733327 200\n210223036 194\n165556044 504\n582885822 230\n769216927 915\n304850218 374\n24767095 594\n512403844 134\n665405724 597\n403298427 211\n385660388 656\n547470144 475\n72464695 870\n878781221 286\n784016743 884\n862594162 355\n951306134 723\n214004862 190\n607476978 912\n360014474 349\n967450966 303\n81389104 640\n143742778 189\n521380719 172\n852488601 236\n595032147 448\n719796110 48\n626683592 627\n570387030 298\n224354875 15\n713085163 251\n501148504 415\n520191862 777\n488460353 526\n713940740 161\n567191120 687\n730738240 152\n66402073 995\n863723779 933\n613800773 697\n542513724 317\n478181891 831\n272840689 17\n388644643 83\n651295444 124\n669936435 966\n703650119 248\n27918078 739\n919057011 725\n515223655 442\n42360434 365\n23279777 305\n887985170 616\n156310648 147\n",
   "199\n733181510 6377\n364841043 4379\n508628307 2045\n637874268 3769\n562967186 89546\n402177883 5093\n156680185 6948\n290965341 3637\n72980661 5739\n464584112 2658\n240241266 1451\n465215914 7066\n50150797 384\n351272902 4962\n52772165 6629\n486969443 26449\n451917804 26414\n681142898 26856\n305843331 5774\n405173991 7183\n243789323 7528\n466131307 2219\n339933065 4334\n743865316 5558\n553001440 8512\n244216126 4024\n845371984 1381\n79987862 9554\n621863375 7562\n238657726 8927\n783179850 7729\n797589220 7902\n168390210 2955\n779745060 3455\n809696757 5893\n842232106 44234\n789725028 1195\n694447741 69022\n731082687 880\n140168884 4550\n729984894 601\n768592705 8764\n435098851 6173\n560169066 6535\n239293060 8229\n74046745 1731\n550471170 8171\n148516706 7118\n961768785 391694\n96147731 8437\n726407435 601\n555950157 82076\n350183985 5802\n654306183 721\n848957927 2561\n865692219 9542\n228638376 1871\n616107106 3888\n58064592 1576\n351272902 4962\n831912135 2950\n816942010 4261\n188510934 8190\n203200972 5715\n834870764 3975\n830553304 9551\n354730434 4761\n562642053 4462\n816928137 407\n627885623 1425\n274558880 23879\n371931737 530\n532362028 3915\n984157741 515\n986456580 9777\n50472801 5595\n599927140 2890\n837742287 2583\n533769920 1060\n729164233 887\n406146832 6207\n35088406 3972\n399890413 28330\n666731960 6015\n699303021 6728\n682510436 8999\n787922745 7644\n568376412 3296\n875406211 2675\n604539822 5597\n249290821 2278\n962639305 2679\n162013311 2963\n497739059 6971\n781785463 5108\n498598260 5018\n881534216 2645\n114900235 2343\n22390116 365\n677322335 4800\n273308638 9882\n854617441 8232\n806581500 7650\n364308122 1147\n781019472 8005\n712016137 6319\n121555203 875\n965266397 406\n8959198 5054\n542999138 7768\n403482550 969\n380594845 2631\n150148055 38558\n304387737 9516\n896629721 47697\n958880605 3503\n983440353 2700\n823355949 1096\n778765223 124734\n822169362 7364\n538487585 2660\n885841145 507\n820189145 1194\n279899404 909\n411389973 9452\n271326687 1726\n935873950 6606\n238028708 7102\n233257883 9397\n789170688 8582\n752827030 757\n942893362 9809\n723008060 2371\n131025464 5737\n654475924 8506\n232457005 9645\n304733490 9328\n744002137 6148\n395476378 1721\n925983451 4319\n213914409 5084\n271281356 1011\n172336393 7497\n191869653 8697\n535725345 8041\n876952812 6384\n658120344 57685\n37126929 1568\n246269078 6423\n222144719 4053\n201134832 5480\n159119234 7131\n363661855 20957\n255403263 9071\n311534904 4685\n118916924 2444\n134116123 9329\n771710889 7603\n444188559 5380\n540217486 3932\n966697008 5681\n743350413 6743\n270042020 5625\n636806790 3808\n50736435 4097\n637982471 12947\n231882853 5157\n852119263 921\n538950019 5253\n686597870 54368\n247308480 7770\n524431034 9328\n788491069 5676\n193825427 11543\n161179381 2533\n240412697 13018\n138455302 4731\n926888737 679\n799961539 5015\n912697738 35698\n769065532 123\n793418126 688\n681018951 2155\n559844993 9212\n770192228 4146\n767635297 8154\n463340708 810\n430656098 44826\n247404441 9314\n853718881 8396\n752332071 4094\n817714396 5120\n598674748 1904\n805588251 7578\n678393303 6020\n110039978 41320\n743106753 9519\n529104453 4297\n444333041 706\n",
   "198\n206855748 7812\n600305914 3899\n784170124 241222\n789614647 4974\n68161664 751\n853334198 765\n249198415 1944\n343094108 6213\n338162362 4518\n143564027 2909\n51680167 5792\n710633731 34335\n716672472 8966\n345750145 8282\n794082900 3786\n849859045 9401\n845441203 120\n352854132 4734\n782056227 3435\n962270293 4576\n930362155 2959\n642334635 1825\n766401383 2529\n682398998 46113\n591436424 6927\n995187794 33316\n189594289 8304\n885156412 52910\n551777115 3379\n922834072 30584\n252030286 3407\n941626246 8418\n881133771 6334\n202350166 8863\n613515896 2157\n46349194 9833\n270078394 3233\n663553075 2992\n901120656 6562\n513737985 6359\n531496076 3593\n891545044 4184\n778677371 7046\n528910594 9456\n415790242 1198\n969382222 4005\n215668136 2647\n530335698 1752\n613556024 78434\n640884386 1926\n885193389 8965\n908300741 15033\n607990565 7139\n797470888 5677\n210905620 4167\n375822355 4692\n156754537 4921\n518766519 4023\n230881011 6297\n135208504 23865\n212855301 8172\n128687830 5084\n425954161 9679\n964998520 4759\n699303021 6728\n347418563 4112\n503290808 1026\n422916022 3433\n617164100 2016\n227706346 2333\n833671339 4821\n283768353 6972\n346659795 7692\n9456953 5907\n600570823 2416\n618816895 3047\n220441879 2647\n40036458 9784\n452339904 2103\n68824261 3659\n763525244 2443\n986087957 9104\n673137093 8320\n477238083 8796\n412207175 4522\n524095506 9627\n829976320 5681\n311861793 7966\n51616991 173\n774431038 8137\n563470585 8375\n866806526 27065\n68161664 751\n544005493 2302\n93856760 3896\n462077274 4407\n913864561 3230\n710983775 675\n677451443 4086\n916492185 8663\n654585952 5237\n187366600 4042\n916172251 8981\n199798306 9227\n362656931 6527\n503827934 1418\n575202772 1564\n474039885 7923\n529508117 82\n18136578 1667\n160376857 102\n851147910 9363\n280831196 3791\n896824338 4439\n872196555 7624\n925213965 3169\n486703067 2085\n945599712 2544\n646978943 5897\n508529849 2483\n548703155 5398\n637874268 3769\n322825248 3139\n933700412 36726\n947324779 2159\n463751165 108\n65209336 5580\n688500482 8906\n981747304 5640\n359357433 6208\n866164562 3200\n586830100 604\n139040060 8191\n24379410 1492\n827570509 9641\n924333159 7678\n69775173 223\n34463061 82\n956522385 3826\n295537536 9612\n410828172 9499\n542937535 8944\n840484996 4338\n271116323 2362\n349482591 1961\n905551056 5023\n117761019 1129\n978984638 3822\n706003980 4246\n851268739 549\n934526676 843\n386977981 5626\n713086200 8330\n743597624 98783\n402086980 4832\n140378053 1677\n804883504 4691\n669706214 5865\n440239911 6761\n397088428 3899\n850794423 89395\n794572076 9995\n989373579 8098\n202977863 9948\n691137158 5895\n464554495 2881\n830355385 6949\n599175192 6167\n101570938 3847\n480954202 3969\n962029598 7145\n900127120 9723\n970409059 2569\n341712759 6035\n931665769 9642\n956373192 52662\n671967612 4507\n170875041 9436\n62910318 6867\n286344049 4959\n188581653 7840\n940382501 9651\n686463170 1257\n930333794 9509\n255491087 8773\n387664802 9158\n546653436 8665\n935309147 6413\n184401469 2776\n830091196 8063\n734327024 6131\n515810907 8351\n390595036 856\n385165739 68674\n433370190 2134\n947766757 3565\n929397500 2709\n642081663 884\n",
   "200\n949544415 39883\n669151150 24191\n253761540 32261\n853903207 5077\n819376661 67587\n506347514 69983\n383168162 26819\n705538858 83800\n609047805 25767\n458854590 74641\n932707210 44285\n836578802 46082\n773331654 95709\n731977150 62680\n711979662 76666\n692668057 8391\n991899933 42755\n126318983 3171\n787316957 54738\n988060508 58567\n458454571 55528\n666437963 7650\n765328411 63584\n231938704 23009\n487930006 46688\n941981459 25649\n301182303 52007\n714664779 78192\n622418326 46379\n584291928 78851\n924781601 67360\n581971092 59841\n854935905 38879\n366574968 35296\n925375270 477949\n657050862 74458\n992035141 86810\n663671260 6351\n960638185 71103\n754351240 16497\n423613071 61646\n812727190 45377\n402936593 11821\n715059758 32390\n463235172 99563\n869931192 43865\n678192125 94071\n789240110 23242\n433578723 34234\n433782124 46965\n891770630 38724\n160642741 10966\n800651788 58885\n769575995 36513\n544606018 42223\n473040294 15330\n629443654 17169\n638828862 17583\n302443779 34472\n509154389 5896\n41212581 2179\n850490325 41071\n403879302 44258\n660011610 78265\n715278787 38249\n426880814 4319\n564598021 26305\n757119594 29747\n812591284 20781\n779884823 67121\n908964951 86791\n664664087 90589\n389044680 1379\n960939639 70852\n595682561 36594\n259638761 8726\n556825008 89158\n59390437 12142\n426937748 58345\n912650450 31856\n282063939 77960\n895098032 8582\n503986736 8027\n59974403 7692\n910359547 39199\n9456953 5907\n819193740 5126\n404113306 53942\n579794719 68911\n277800051 7441\n933233317 99728\n937800691 82767\n285673249 53786\n611920647 81223\n268888934 22336\n334531814 54734\n111726054 16654\n592914243 92099\n982596243 50362\n736110245 1361\n456086134 38772\n571415114 80883\n702263902 45405\n579794719 68911\n926345037 71090\n456204926 26838\n285157205 45899\n857482161 43068\n596739767 69079\n539939116 58961\n565312299 7796\n795952327 35411\n157193157 26051\n625895509 29523\n177645953 15869\n186603664 98407\n710772608 6786\n513828187 13333\n360746547 91559\n784693586 84640\n739151328 55647\n644305373 87858\n965275340 73982\n486969443 26449\n66062800 16213\n400246204 42587\n139908858 28946\n505256100 32805\n497543154 35364\n744196291 59711\n541004675 8197\n840944534 49156\n404938648 38638\n769767986 59090\n281048408 16382\n375016237 76276\n586285724 89320\n995398759 109191\n326837873 6623\n545810426 88559\n780370345 1563\n340612245 5785\n381529336 64883\n819991448 57099\n978745602 87790\n417258626 678\n250690679 38111\n284473705 52503\n685572720 27651\n228734393 61416\n627483917 46811\n549784503 5853\n300800788 50220\n923000434 53133\n813163768 80160\n475145517 8315\n902123352 27289\n545294072 78132\n854980275 10121\n531626998 91711\n763262448 68247\n272970813 39051\n298285862 22900\n55847147 19728\n705538858 83800\n640979852 11619\n888825306 32128\n908043943 23998\n678192125 94071\n330483971 864\n961660423 86754\n784778974 60453\n467264054 35097\n566184235 25327\n680639511 40088\n179284701 10825\n995135233 52336\n828938171 1670\n501692910 40155\n375016237 76276\n847823766 29797\n731466459 84051\n250690679 38111\n660397272 67516\n343710255 19108\n708513384 64091\n341928461 59984\n415609765 10557\n96363956 20094\n616590534 33256\n580141863 33850\n896555207 17435\n690356012 90227\n447487349 7423\n360885123 13381\n927839720 91196\n445929921 30126\n980664846 138934\n679342371 16776\n533547795 2734\n",
   "199\n163814943 9140\n707508685 35506\n888070531 46176\n794245884 5430\n743597624 98783\n202574001 8260\n173319850 20589\n497734955 66148\n795952327 35411\n691897891 1109\n662077727 67452\n381566768 13725\n303252370 5528\n330365328 28056\n829275899 17660\n993667133 5493\n434108579 92791\n485458275 16779\n150491918 62291\n133833726 33856\n36372154 15616\n907963580 36100\n178505668 50421\n633289521 75247\n769041121 121006\n59300065 29852\n749877169 60341\n648301860 3072\n60661540 135\n109249304 17159\n414448656 20783\n599027699 81246\n614513609 95701\n266775839 27554\n62441060 3348\n927082589 52226\n440512490 97680\n233189150 5696\n407732887 19201\n891827014 23842\n604140382 14016\n784310795 24646\n640026061 62767\n779372780 63678\n282916315 95214\n813455202 5016\n580141863 33850\n452599630 52219\n949798859 54561\n692382518 36035\n921498076 86894\n309739180 13439\n491903095 62105\n851419769 11460\n186799284 9774\n761805146 58521\n327740446 17249\n705043065 48847\n717952469 46510\n734712698 67575\n656559523 88961\n243618572 3916\n895098032 8582\n523999154 21486\n937220858 65853\n38266445 10117\n346847251 74806\n741486913 12502\n753104919 32731\n50308021 23566\n959678779 32787\n130788616 7818\n284561405 1173\n926794189 51112\n206113992 54924\n186603664 98407\n582524043 59829\n666707781 24831\n458038604 31054\n307109617 76213\n965561613 24824\n548371808 9302\n89955777 9897\n637953903 60700\n732960006 26620\n855862092 38405\n517924678 14562\n693797449 44990\n569259506 106885\n730196745 71718\n675142155 38430\n854783874 9193\n124385225 82354\n968319767 97494\n691971175 33564\n934883322 29468\n644475485 60620\n872794822 38929\n592914243 92099\n851980891 40557\n239533531 19243\n506347514 69983\n831352460 76171\n624305687 62653\n979092023 663803\n704046082 4887\n245882966 76426\n461981444 28438\n692930380 45124\n631237206 81634\n722006385 8854\n925375270 477949\n37279799 9563\n264083175 48942\n236521179 91183\n950126693 75410\n47502197 24458\n546055851 100019\n766405879 95484\n392002935 55892\n346572307 23379\n146467244 47670\n396273335 42052\n287349199 643\n482744509 92400\n685542262 9831\n493687052 34982\n914935943 32661\n35737743 5490\n333048117 36203\n677746647 66444\n241980397 17791\n293012381 379\n871895945 47414\n890131347 90108\n854992903 28285\n340612245 5785\n999618735 16533\n682822807 43445\n707191841 67328\n540282684 86346\n735379560 44651\n324744369 59233\n403879302 44258\n794686618 40575\n915743455 81413\n491529332 93191\n977857824 98748\n773654445 56497\n241053370 84548\n642790229 51010\n228191331 97974\n657812456 44571\n748520268 119049\n237906896 66212\n970991887 62978\n617611727 629840\n456309617 35910\n972844644 34475\n308853661 67849\n544334339 98845\n880737694 89332\n100656901 48078\n571661550 28169\n833707117 72550\n855040894 18736\n901914348 81746\n652148110 26672\n565651222 28657\n995474696 813\n38749882 7808\n280070773 21288\n201052503 81556\n866931394 87914\n97657935 10722\n790517405 48804\n940278468 51246\n62065779 8036\n613959473 48877\n869043816 388338\n261732385 16729\n894970533 56803\n354861679 142183\n753753310 41258\n980048336 34221\n438307537 30108\n50446279 8418\n228790388 13563\n489580995 29278\n671427113 54441\n289919431 3986\n855555940 35186\n427127871 47102\n135350638 78698\n502427738 67694\n196168914 98994\n537167069 53938\n735100268 83161\n963721531 75782\n",
   "198\n381566768 13725\n704542994 48855\n89955777 9897\n915400360 26767\n592917888 79581\n323313084 4198\n817686510 80935\n134885729 49135\n150148055 38558\n962652893 97503\n847600889 87498\n855040894 18736\n368416992 48372\n997472540 84280\n325771747 249786\n110958180 24941\n150148055 38558\n995606443 87753\n795148944 27382\n732460695 46268\n515144173 230323\n395612794 18690\n690356012 90227\n595682561 36594\n895587809 6710\n20862081 6733\n826459375 71831\n980567373 138638\n951871094 163875\n819321911 7370\n991260291 418800\n426937748 58345\n951871094 163875\n957911428 9821\n421016412 180957\n857876716 793827\n382940609 41966\n378800564 93550\n933637207 78152\n249000086 92800\n846910842 197749\n763572011 86994\n243360594 12550\n977683169 185667\n378792225 95520\n157434103 9232\n919563405 74653\n894036016 76299\n282053471 9418\n149269384 16633\n960264500 189302\n594306946 94803\n261732385 16729\n522950658 6207\n614513609 95701\n515138776 88136\n953883761 76036\n995606443 87753\n20862081 6733\n161683649 176518\n426212925 249203\n949035572 421371\n289616649 40336\n934362641 6266\n140998950 62749\n188467256 39293\n512582354 50321\n28035117 5642\n229805211 72274\n659700470 39536\n691936310 201152\n645081347 96374\n568058186 15391\n298176233 7616\n676356072 56209\n849755558 46983\n350457846 196329\n981735726 330714\n480773562 16447\n932562181 341106\n850227381 3306\n194229642 39948\n41240006 19152\n190098080 41089\n659979162 415767\n29892720 12242\n14418192 5417\n33138796 6571\n597913166 30645\n812350137 647766\n422654052 6190\n464455070 38596\n323313084 4198\n927082589 52226\n884028012 56651\n426212925 249203\n849755558 46983\n703976064 665623\n749065790 81888\n499623906 90112\n333234272 59864\n644028911 64758\n795854909 213687\n743597624 98783\n278509721 55622\n195561201 84266\n456390440 67016\n699297380 90836\n769041121 121006\n917621961 90650\n79150807 8977\n928898128 498400\n754185961 245658\n615387678 7371\n249000086 92800\n325771747 249786\n266960204 93431\n850227381 3306\n802719120 512195\n151867067 7144\n368246545 114380\n927082589 52226\n821231872 228632\n690356012 90227\n125073507 46044\n4753165 2558\n735531130 222276\n775987805 15471\n877243196 408440\n921046134 313759\n87124238 5362\n41212581 2179\n821231872 228632\n790425149 480960\n59974403 7692\n373853779 77948\n188800057 38364\n978246763 45340\n96363956 20094\n895098032 8582\n431260939 100737\n89955777 9897\n549049047 73684\n846910842 197749\n244562920 48507\n768590296 82821\n368246545 114380\n991260291 418800\n512960753 65122\n561170800 215460\n438558824 98191\n37558984 950\n547956094 180051\n179573141 21242\n403508450 71706\n506889489 85449\n905154139 140284\n933700412 36726\n389746510 44611\n773846189 96074\n414448656 20783\n972208545 237340\n903589150 69005\n884990456 47741\n262602442 25478\n995606443 87753\n354697490 42941\n604541075 87220\n956373192 52662\n442082931 6133\n299987401 2678\n699297380 90836\n705575559 77915\n690356012 90227\n689293336 212307\n995980995 8450\n794605017 47245\n846679033 35893\n320017083 47792\n884028012 56651\n625076118 59547\n632803822 40500\n923938745 176645\n59390437 12142\n59390437 12142\n869702792 79627\n458454571 55528\n614993522 533601\n301455776 64667\n348089574 27007\n206011651 35138\n996685921 426783\n698970695 86111\n806904102 165129\n227301987 17126\n971535996 67551\n443523137 58400\n621666874 5266\n",
   "200\n346848949 14388\n448538936 8403\n426212925 249203\n17750147 8055\n545810426 88559\n304386085 45874\n17915780 5024\n326461249 63548\n562609085 9903\n83669790 7217\n581112859 257194\n296991335 59490\n625895509 29523\n579794719 68911\n795956567 421081\n369706511 98848\n773654445 56497\n349302291 82702\n714380286 30040\n596739767 69079\n301455776 64667\n139908858 28946\n426212925 249203\n381566768 13725\n819494616 14948\n357218781 69810\n250253057 71624\n111126107 93893\n82903483 43971\n300959622 52599\n817686510 80935\n637982471 12947\n24456181 7735\n519647448 43619\n186528805 89862\n311426910 57251\n972893294 150995\n609008191 100453\n267928065 87202\n857396368 9171\n588193872 94518\n915827967 71105\n582411662 66036\n86403392 5770\n692382518 36035\n461812665 81378\n685572720 27651\n589277146 124027\n385552669 66311\n536514174 52063\n243360594 12550\n368246545 114380\n978246763 45340\n963243408 283032\n9456953 5907\n875693332 374154\n276899772 77086\n7564888 1370\n360764090 24448\n282916315 95214\n265356949 57346\n917621961 90650\n21031091 2559\n21968679 9192\n458454571 55528\n531626998 91711\n819321911 7370\n836975131 88700\n939309497 308456\n978246763 45340\n495099317 67264\n512312652 86987\n884990456 47741\n464895475 32397\n932562181 341106\n700864488 137532\n354697490 42941\n908300741 15033\n455871793 17261\n976297439 297458\n549502079 9360\n996685921 426783\n899943346 952628\n48136349 9977\n632078218 39571\n542274012 75667\n353632232 97369\n659700470 39536\n777268724 82304\n207111206 8289\n448217368 17666\n534363623 247525\n444188559 5380\n546055851 100019\n528873117 95312\n895098032 8582\n48731285 8819\n448538936 8403\n883815943 437313\n237155404 7993\n14418192 5417\n176922003 8144\n945448292 914337\n791535983 283416\n119929688 19189\n704542994 48855\n42510109 6281\n298176233 7616\n662877033 200276\n293338624 91848\n875800981 345262\n594110851 363227\n776158267 317613\n723662107 514940\n959315804 7721\n206011651 35138\n421016412 180957\n645042708 1583\n82903483 43971\n410717344 37980\n819321911 7370\n819321911 7370\n169779867 39724\n956373192 52662\n972208545 237340\n616881517 47937\n367321651 73450\n917608682 322783\n848280934 75777\n847845934 31787\n915400360 26767\n596739767 69079\n334547790 60981\n632078218 39571\n297500366 26043\n136664346 9784\n471647270 22751\n689006429 474481\n865512219 392869\n391203309 60158\n499623906 90112\n345099530 68973\n579794719 68911\n293338624 91848\n46575221 7895\n769041121 121006\n628680080 377345\n72678674 27032\n951725143 314176\n948476038 185261\n817562687 33352\n918443721 172365\n503387829 307697\n57503146 5000\n625895509 29523\n549049047 73684\n769041121 121006\n668415060 52136\n53830256 7843\n295077952 6219\n672083615 78760\n428568942 78021\n96363956 20094\n549502079 9360\n898849397 202394\n582411662 66036\n212457924 6513\n601420005 93878\n336217937 5742\n332581576 5450\n61311237 16923\n335935252 42824\n320293116 7301\n922981065 322691\n898543552 45188\n723662107 514940\n621631882 27385\n742786683 333166\n769041121 121006\n632078218 39571\n579794719 68911\n299987401 2678\n763572011 86994\n770815147 95661\n932294630 422099\n584463306 54725\n869043816 388338\n904226790 146355\n55421219 5609\n308853661 67849\n96363956 20094\n149269384 16633\n959377266 528776\n991679556 37770\n991260291 418800\n747077610 33761\n426408689 62774\n11359628 2198\n371694719 70063\n778765223 124734\n",
   "199\n588193872 94518\n595402656 325274\n838856448 60975\n378792225 95520\n615387678 7371\n769041121 121006\n509511675 63680\n769041121 121006\n194229642 39948\n854992903 28285\n195561201 84266\n171027800 1103\n368246545 114380\n769725774 25096\n83669790 7217\n448538936 8403\n579794719 68911\n802719120 512195\n588193872 94518\n869702792 79627\n883815943 437313\n20151253 972\n615387678 7371\n588193872 94518\n977683169 185667\n786719164 52965\n769041121 121006\n869043816 388338\n195561201 84266\n932562181 341106\n769041121 121006\n381566768 13725\n325771747 249786\n769041121 121006\n236521179 91183\n869043816 388338\n194229642 39948\n588193872 94518\n813545700 87191\n82903483 43971\n951871094 163875\n972250525 664964\n381566768 13725\n89955777 9897\n917621961 90650\n184736872 5231\n464895475 32397\n426937748 58345\n53830256 7843\n60312274 61882\n385552669 66311\n869043816 388338\n588193872 94518\n776158267 317613\n826459375 71831\n588193872 94518\n59390437 12142\n917621961 90650\n956373192 52662\n579794719 68911\n243360594 12550\n995606443 87753\n21031091 2559\n378792225 95520\n903589150 69005\n794605017 47245\n385552669 66311\n199474497 75122\n368246545 114380\n869043816 388338\n895835659 30305\n579794719 68911\n806905904 401768\n956373192 52662\n59390437 12142\n298176233 7616\n293338624 91848\n588193872 94518\n426212925 249203\n588193872 94518\n194229642 39948\n37558984 950\n977683169 185667\n535467612 271765\n769041121 121006\n611773606 234519\n903589150 69005\n514627668 69800\n514627668 69800\n421016412 180957\n528380516 52525\n836975131 88700\n776158267 317613\n963531528 388716\n195561201 84266\n21968679 9192\n895098032 8582\n592917888 79581\n186603664 98407\n426212925 249203\n836975131 88700\n956373192 52662\n954258174 445486\n503387829 307697\n588193872 94518\n869043816 388338\n836975131 88700\n368246545 114380\n378792225 95520\n927588717 75443\n883815943 437313\n541408157 467417\n588193872 94518\n243360594 12550\n445929921 30126\n978246763 45340\n869043816 388338\n769041121 121006\n826459375 71831\n995606443 87753\n150148055 38558\n59390437 12142\n338323996 27875\n421016412 180957\n293338624 91848\n579794719 68911\n68858312 7971\n426212925 249203\n190098080 41089\n817686510 80935\n617611727 629840\n995606443 87753\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n841416919 67259\n59390437 12142\n769041121 121006\n884990456 47741\n506347514 69983\n150148055 38558\n150148055 38558\n806905904 401768\n899943346 952628\n139744917 34906\n588193872 94518\n83669790 7217\n857876716 793827\n378792225 95520\n514627668 69800\n310033144 92894\n884990456 47741\n977683169 185667\n506347514 69983\n83669790 7217\n59390437 12142\n617611727 629840\n869043816 388338\n617611727 629840\n769041121 121006\n426212925 249203\n956142614 468480\n41885413 8336\n390950955 76118\n390950955 76118\n21968679 9192\n448217368 17666\n461812665 81378\n995606443 87753\n656961764 82771\n495099317 67264\n33138796 6571\n444188559 5380\n895098032 8582\n195561201 84266\n243360594 12550\n817686510 80935\n381566768 13725\n864514293 345101\n339449168 59432\n951725143 314176\n813545700 87191\n769041121 121006\n218355674 117274\n869043816 388338\n769041121 121006\n869043816 388338\n895098032 8582\n465884779 79499\n150148055 38558\n195561201 84266\n171027800 1103\n426212925 249203\n990085562 246235\n617611727 629840\n43119235 14794\n769041121 121006\n289616649 40336\n",
   "198\n995606443 87753\n310110485 54342\n831987173 345117\n588193872 94518\n813545700 87191\n936987212 42293\n977683169 185667\n135858339 93985\n857876716 793827\n776158267 317613\n956373192 52662\n186603664 98407\n802719120 512195\n186603664 98407\n588193872 94518\n977683169 185667\n444188559 5380\n588193872 94518\n902213959 77751\n995606443 87753\n995606443 87753\n464895475 32397\n237155404 7993\n495099317 67264\n802719120 512195\n776158267 317613\n421016412 180957\n230093862 19138\n464895475 32397\n484862372 73347\n981735726 330714\n775987805 15471\n977683169 185667\n619178689 194464\n243360594 12550\n857876716 793827\n869043816 388338\n644475485 60620\n356971011 95264\n125073507 46044\n68858312 7971\n381566768 13725\n869043816 388338\n995606443 87753\n448217368 17666\n46575221 7895\n516926955 198823\n21968679 9192\n466178675 226935\n895098032 8582\n548348988 54707\n802719120 512195\n46575221 7895\n89955777 9897\n302928788 9069\n378792225 95520\n978246763 45340\n325771747 249786\n997656195 70629\n772523050 40525\n186603664 98407\n642790229 51010\n243360594 12550\n617611727 629840\n503387829 307697\n243360594 12550\n368246545 114380\n995606443 87753\n68858312 7971\n60312274 61882\n956142614 468480\n464895475 32397\n82903483 43971\n426212925 249203\n879693631 42194\n588193872 94518\n464895475 32397\n236521179 91183\n339449168 59432\n644305373 87858\n936168572 74903\n68858312 7971\n995606443 87753\n915422821 406621\n368246545 114380\n769041121 121006\n927588717 75443\n617611727 629840\n775987805 15471\n353173131 21943\n390950955 76118\n150148055 38558\n922295365 852062\n381566768 13725\n703976064 665623\n243360594 12550\n325771747 249786\n464895475 32397\n59390437 12142\n385552669 66311\n917621961 90650\n46575221 7895\n339449168 59432\n956373192 52662\n237906896 66212\n981735726 330714\n325771747 249786\n588193872 94518\n901888671 268945\n65894622 40128\n714380286 30040\n763262448 68247\n617611727 629840\n334547790 60981\n11889537 5179\n41885413 8336\n802719120 512195\n171027800 1103\n344444075 58292\n218355674 117274\n901888671 268945\n368246545 114380\n819321911 7370\n325771747 249786\n150148055 38558\n836975131 88700\n883815943 437313\n484862372 73347\n579794719 68911\n195561201 84266\n447222560 116618\n150148055 38558\n895098032 8582\n582524043 59829\n378792225 95520\n385552669 66311\n356971011 95264\n21968679 9192\n194229642 39948\n769041121 121006\n903589150 69005\n817686510 80935\n763262448 68247\n426212925 249203\n776158267 317613\n914935943 32661\n426212925 249203\n150148055 38558\n579794719 68911\n243360594 12550\n195793603 51298\n385552669 66311\n443523137 58400\n385552669 66311\n59390437 12142\n59390437 12142\n237906896 66212\n995606443 87753\n869043816 388338\n644475485 60620\n495099317 67264\n769041121 121006\n915422821 406621\n728608864 65630\n972250525 664964\n620787171 21303\n694447741 69022\n857876716 793827\n836975131 88700\n776158267 317613\n714031345 45096\n83669790 7217\n14418192 5417\n582524043 59829\n426212925 249203\n60312274 61882\n390950955 76118\n769041121 121006\n956373192 52662\n936056346 80234\n194229642 39948\n194229642 39948\n642790229 51010\n615387678 7371\n299987401 2678\n243360594 12550\n864514293 345101\n448538936 8403\n553178202 12182\n899943346 952628\n769041121 121006\n19791425 2868\n396712287 77713\n703976064 665623\n579794719 68911\n171027800 1103\n714031345 45096\n490050886 55890\n",
   "200\n769041121 121006\n59390437 12142\n895098032 8582\n588193872 94518\n869043816 388338\n368246545 114380\n588193872 94518\n995606443 87753\n769041121 121006\n869043816 388338\n617611727 629840\n59390437 12142\n776158267 317613\n869043816 388338\n995606443 87753\n368246545 114380\n802719120 512195\n381566768 13725\n836975131 88700\n769041121 121006\n769041121 121006\n895098032 8582\n617611727 629840\n769041121 121006\n769041121 121006\n426212925 249203\n895098032 8582\n836975131 88700\n588193872 94518\n869043816 388338\n325771747 249786\n195561201 84266\n769041121 121006\n378792225 95520\n368246545 114380\n769041121 121006\n869043816 388338\n368246545 114380\n588193872 94518\n869043816 388338\n769041121 121006\n617611727 629840\n588193872 94518\n769041121 121006\n588193872 94518\n995606443 87753\n776158267 317613\n895098032 8582\n917621961 90650\n776158267 317613\n776158267 317613\n836975131 88700\n59390437 12142\n769041121 121006\n150148055 38558\n769041121 121006\n995606443 87753\n895098032 8582\n821488014 95527\n769041121 121006\n776158267 317613\n769041121 121006\n776158267 317613\n895098032 8582\n579794719 68911\n776158267 317613\n617611727 629840\n368246545 114380\n977683169 185667\n817686510 80935\n995606443 87753\n769041121 121006\n776158267 317613\n869043816 388338\n219378413 70576\n977683169 185667\n995606443 87753\n588193872 94518\n243360594 12550\n21968679 9192\n951871094 163875\n464895475 32397\n426212925 249203\n776158267 317613\n869043816 388338\n869043816 388338\n588193872 94518\n59390437 12142\n769041121 121006\n977683169 185667\n769041121 121006\n869043816 388338\n368246545 114380\n195561201 84266\n59390437 12142\n995606443 87753\n776158267 317613\n895098032 8582\n977683169 185667\n426212925 249203\n995606443 87753\n243360594 12550\n588193872 94518\n895098032 8582\n995606443 87753\n869043816 388338\n96363956 20094\n776158267 317613\n776158267 317613\n995606443 87753\n588193872 94518\n995606443 87753\n195561201 84266\n769041121 121006\n933130085 54861\n368246545 114380\n776158267 317613\n588193872 94518\n817686510 80935\n917621961 90650\n243360594 12550\n776158267 317613\n776158267 317613\n385552669 66311\n995606443 87753\n776158267 317613\n995606443 87753\n883815943 437313\n195561201 84266\n769041121 121006\n776158267 317613\n588193872 94518\n714031345 45096\n769041121 121006\n549502079 9360\n995606443 87753\n243360594 12550\n769041121 121006\n977683169 185667\n956373192 52662\n995606443 87753\n381566768 13725\n617611727 629840\n368246545 114380\n995606443 87753\n869043816 388338\n381566768 13725\n995606443 87753\n642790229 51010\n617611727 629840\n195561201 84266\n977683169 185667\n995606443 87753\n836975131 88700\n995606443 87753\n769041121 121006\n977683169 185667\n769041121 121006\n776158267 317613\n769041121 121006\n368246545 114380\n769041121 121006\n368246545 114380\n243360594 12550\n869043816 388338\n995606443 87753\n769041121 121006\n995606443 87753\n325771747 249786\n995606443 87753\n869043816 388338\n776158267 317613\n977683169 185667\n769041121 121006\n769041121 121006\n776158267 317613\n617611727 629840\n769041121 121006\n769041121 121006\n588193872 94518\n237155404 7993\n869043816 388338\n769041121 121006\n194229642 39948\n977683169 185667\n769041121 121006\n769041121 121006\n769041121 121006\n243360594 12550\n826459375 71831\n995606443 87753\n59390437 12142\n995606443 87753\n769041121 121006\n243360594 12550\n769041121 121006\n195561201 84266\n769041121 121006\n243360594 12550\n462934095 48655\n",
   "199\n769041121 121006\n588193872 94518\n588193872 94518\n869043816 388338\n995606443 87753\n381566768 13725\n895098032 8582\n14418192 5417\n769041121 121006\n997919785 123108\n588193872 94518\n776158267 317613\n769041121 121006\n642790229 51010\n977683169 185667\n836975131 88700\n883815943 437313\n769041121 121006\n883815943 437313\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n776158267 317613\n951871094 163875\n769041121 121006\n995606443 87753\n579794719 68911\n884990456 47741\n769041121 121006\n171027800 1103\n769041121 121006\n776158267 317613\n869043816 388338\n588193872 94518\n776158267 317613\n535467612 271765\n579794719 68911\n995606443 87753\n836975131 88700\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n714380286 30040\n339449168 59432\n227742190 20146\n869043816 388338\n869043816 388338\n769041121 121006\n769041121 121006\n776158267 317613\n769041121 121006\n617611727 629840\n776158267 317613\n769041121 121006\n769041121 121006\n995606443 87753\n869043816 388338\n617611727 629840\n381566768 13725\n769041121 121006\n769041121 121006\n869043816 388338\n776158267 317613\n769041121 121006\n995606443 87753\n579794719 68911\n769041121 121006\n995606443 87753\n995606443 87753\n920478474 510636\n776158267 317613\n579794719 68911\n995606443 87753\n995606443 87753\n995606443 87753\n836975131 88700\n869043816 388338\n776158267 317613\n776158267 317613\n869043816 388338\n769041121 121006\n869043816 388338\n293338624 91848\n535467612 271765\n995606443 87753\n769041121 121006\n769041121 121006\n588193872 94518\n977683169 185667\n769041121 121006\n381566768 13725\n617611727 629840\n339449168 59432\n869043816 388338\n588193872 94518\n977683169 185667\n588193872 94518\n769041121 121006\n588193872 94518\n869043816 388338\n995606443 87753\n769041121 121006\n776158267 317613\n617611727 629840\n869043816 388338\n769041121 121006\n995606443 87753\n755748426 60533\n195561201 84266\n995606443 87753\n869043816 388338\n895098032 8582\n617611727 629840\n769041121 121006\n869043816 388338\n776158267 317613\n995606443 87753\n769041121 121006\n769041121 121006\n776158267 317613\n995606443 87753\n977683169 185667\n869043816 388338\n769041121 121006\n644305373 87858\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n869043816 388338\n995606443 87753\n895098032 8582\n769041121 121006\n769041121 121006\n426212925 249203\n368246545 114380\n769041121 121006\n769041121 121006\n869043816 388338\n995606443 87753\n995606443 87753\n644305373 87858\n857876716 793827\n769041121 121006\n368246545 114380\n977683169 185667\n917621961 90650\n776158267 317613\n972250525 664964\n869043816 388338\n933130085 54861\n385552669 66311\n836975131 88700\n995606443 87753\n769041121 121006\n869043816 388338\n977683169 185667\n195561201 84266\n747077610 33761\n995606443 87753\n747077610 33761\n186603664 98407\n149269384 16633\n769041121 121006\n769041121 121006\n995606443 87753\n298176233 7616\n368246545 114380\n769041121 121006\n588193872 94518\n895098032 8582\n769041121 121006\n776158267 317613\n615387678 7371\n769041121 121006\n243360594 12550\n368246545 114380\n617611727 629840\n802719120 512195\n895098032 8582\n769041121 121006\n617611727 629840\n368246545 114380\n769041121 121006\n956373192 52662\n769041121 121006\n131254701 8989\n615468002 315528\n869043816 388338\n769041121 121006\n325771747 249786\n195561201 84266\n368246545 114380\n150148055 38558\n769041121 121006\n769041121 121006\n836975131 88700\n",
   "198\n995606443 87753\n769041121 121006\n776158267 317613\n769041121 121006\n769041121 121006\n644305373 87858\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n368246545 114380\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n390950955 76118\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n995606443 87753\n769041121 121006\n977683169 185667\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n869043816 388338\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n503387829 307697\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n743597624 98783\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n776158267 317613\n769041121 121006\n243360594 12550\n869043816 388338\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n977683169 185667\n769041121 121006\n995606443 87753\n995606443 87753\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n368246545 114380\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n588193872 94518\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n977683169 185667\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n977683169 185667\n769041121 121006\n769041121 121006\n588193872 94518\n769041121 121006\n995606443 87753\n995606443 87753\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n194229642 39948\n995606443 87753\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n595402656 325274\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n588193872 94518\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n381566768 13725\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n944982997 166506\n995606443 87753\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n588193872 94518\n769041121 121006\n977683169 185667\n769041121 121006\n339449168 59432\n175860042 9026\n",
   "200\n588193872 94518\n769041121 121006\n769041121 121006\n368246545 114380\n769041121 121006\n995606443 87753\n769041121 121006\n869043816 388338\n995606443 87753\n769041121 121006\n995606443 87753\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n776158267 317613\n769041121 121006\n769041121 121006\n617611727 629840\n813545700 87191\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n96363956 20094\n769041121 121006\n869043816 388338\n617611727 629840\n59390437 12142\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n390950955 76118\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n776158267 317613\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n869043816 388338\n995606443 87753\n769041121 121006\n776158267 317613\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n195561201 84266\n368246545 114380\n769041121 121006\n769041121 121006\n588193872 94518\n769041121 121006\n895098032 8582\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n237906896 66212\n869043816 388338\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n869043816 388338\n995606443 87753\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n243360594 12550\n776158267 317613\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n776158267 317613\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n190098080 41089\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n243360594 12550\n995606443 87753\n769041121 121006\n869043816 388338\n339449168 59432\n995606443 87753\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n995606443 87753\n769041121 121006\n995606443 87753\n769041121 121006\n995606443 87753\n869043816 388338\n769041121 121006\n995606443 87753\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n769041121 121006\n769041121 121006\n769041121 121006\n368246545 114380\n769041121 121006\n769041121 121006\n769041121 121006\n243360594 12550\n995606443 87753\n776158267 317613\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n987462366 49105\n869043816 388338\n995606443 87753\n869043816 388338\n769041121 121006\n769041121 121006\n769041121 121006\n769041121 121006\n995606443 87753\n",
   "199\n457467917 7350\n668718844 6384\n397836664 988\n386447235 2666\n664888758 958\n784148628 2332\n317733706 6010\n950159194 9138\n48344554 4183\n643092461 4808\n914118159 6433\n804613507 56528\n995949270 5011\n345353240 5032\n533769920 1060\n446672196 66590\n834365244 3203\n477719868 50189\n144199070 873\n175510045 7283\n794692980 824\n741024259 2393\n607057305 2695\n743530112 7928\n738621803 2194\n783422594 2165\n960638185 71103\n725040261 6558\n602641898 510\n831484374 166\n590816693 5269\n231242545 7375\n9905756 895\n496060609 7527\n300502721 6231\n622111721 9534\n397058622 8989\n593276344 9968\n406277070 3757\n531401554 2850\n941125295 6484\n732679342 5223\n750494141 97556\n510921043 8188\n364782788 1681\n825120770 7134\n148888796 5102\n947394899 7361\n486092044 4007\n119821193 2147\n88754240 182\n502504113 5977\n209969990 43\n798761933 8219\n920781316 943\n755064541 6340\n992377865 8570\n628905508 40959\n672954516 8873\n717798267 5581\n312585769 6033\n622259138 4136\n96659618 1766\n454071858 3434\n376285141 5212\n390987734 580\n708733854 2381\n827731278 9071\n995980995 8450\n37279799 9563\n633208716 4092\n701464444 2619\n860594864 4412\n512294891 8778\n133832207 6646\n292712380 7889\n262839615 5202\n90159930 6601\n522792156 8797\n78938357 644\n61314844 766\n146280611 39\n192570236 9141\n53042775 2946\n601358100 8756\n274542879 1071\n509140164 9650\n170732478 2836\n304726058 1626\n701958640 9224\n138070843 7804\n760828115 25767\n107931112 9204\n620957490 7192\n411389973 9452\n407618675 6758\n482815460 8421\n440272758 707\n675699452 7938\n465215914 7066\n78167170 8243\n260245728 445\n76046347 1634\n378792225 95520\n652273720 7209\n129259453 8865\n79251693 5243\n114379094 7891\n212855301 8172\n654306183 721\n579210378 8231\n367883151 5148\n419734738 6660\n835226477 4020\n52969503 4733\n9349924 2093\n28035117 5642\n845390952 3582\n57422641 7376\n594116821 9519\n720401739 9333\n834779815 4392\n494263520 45514\n773094277 1887\n371811281 1792\n878845441 4917\n400420041 46471\n887290608 3459\n130241685 8147\n615292068 614\n863730393 7031\n850227381 3306\n388529713 1909\n688510338 1511\n250497238 8646\n945733412 34351\n71955172 7260\n398575226 7951\n570755645 377\n228638376 1871\n369567130 2086\n904457988 4908\n545664039 9468\n978810644 9012\n402177883 5093\n827234643 166775\n292766098 792\n178960691 5368\n712016137 6319\n398377829 289\n661989766 8444\n115821612 9303\n593920712 9356\n991204222 4109\n571039428 7618\n709129737 7745\n572429562 1695\n435993889 6477\n548316661 998\n952418218 6331\n830284194 2470\n801089795 4211\n572959906 2963\n583051751 7112\n855355606 2776\n221119230 4610\n933866710 3783\n78917734 1480\n73674907 9349\n186735024 5346\n960881377 9453\n198431749 528\n334570347 401\n324345952 2504\n699180998 1214\n591411260 3971\n831015566 7527\n766995906 4851\n49036489 5896\n84767004 5500\n131627465 3831\n738487833 4381\n580265219 4933\n951761713 2717\n171718636 7227\n184405814 5636\n825120770 7134\n911186721 6257\n945733412 34351\n255728969 7584\n757711863 2615\n628357647 2680\n959315804 7721\n96133637 7767\n804208190 2132\n774798626 5408\n906031260 2877\n356733750 692\n884251529 69799\n",
   "198\n39954571 4978\n441432490 3941\n96133637 7767\n261913571 2873\n98517258 6043\n917686676 7999\n433036773 5895\n864288731 2419\n189129357 7827\n613600016 9716\n700982746 6774\n234307857 6476\n475227892 2772\n174325045 8629\n639079665 1983\n671967612 4507\n174641691 6445\n957570868 36540\n998689329 69358\n734327024 6131\n683170395 98301\n382918752 558\n67645997 5904\n56199483 6927\n730178469 7575\n455216780 9836\n374952673 4918\n726027103 8179\n985897390 7929\n244216126 4024\n94522929 6253\n235193619 630\n99954889 5135\n74559863 7065\n203273415 5157\n574503915 8383\n192299608 7485\n789055403 7433\n275553799 40312\n863411395 633\n866225811 471\n964331085 2058\n967980843 9972\n331175097 8325\n762159155 5252\n515810907 8351\n895134799 8189\n763812256 5635\n387173638 206\n562274190 3428\n525764081 6648\n81675259 8396\n819414138 7400\n130276045 5570\n466137878 2388\n620356941 7370\n492395628 106\n512578724 8525\n717452068 8076\n498102102 68648\n378558851 1724\n406481725 5211\n568734345 6786\n882180182 9171\n107255670 8979\n318598450 4298\n44060724 1750\n940805842 97165\n838731777 8291\n573477820 1331\n433819230 9166\n602349772 669\n538161141 7205\n270195719 3762\n516630196 9489\n556023278 4199\n949040449 6089\n325971851 7888\n619365362 8934\n164705729 1341\n567975074 16188\n297928172 7708\n101458454 2598\n641294676 7838\n882652397 6684\n79251693 5243\n774431038 8137\n124691915 4241\n945599712 2544\n589759215 7484\n941148732 25212\n410024072 4893\n623742942 1793\n399520269 6689\n947672374 52815\n23120264 892\n258813578 672\n9905756 895\n877408093 417\n78917734 1480\n740892091 53177\n875739607 5337\n675471058 42840\n968810134 4538\n573132514 43743\n718172424 386\n305452356 1976\n959906427 7778\n172014904 972\n262705808 19678\n744358777 8274\n302534240 85935\n962029598 7145\n970659480 7030\n562176675 9498\n606355217 4707\n569339877 2407\n681566623 8069\n548929393 50719\n196232885 7360\n895227853 4601\n627901500 2390\n262177063 951\n79790442 9900\n681011350 6608\n166893720 4981\n786783271 8002\n813778792 4372\n857876716 793827\n652862008 1669\n344587314 16321\n261732385 16729\n301607683 993\n531895205 7493\n500903098 2583\n469058359 6036\n490144603 8349\n624724613 1664\n438297355 5831\n729190536 8951\n618360075 52\n514015348 8690\n517225918 5411\n766754256 4624\n744371928 2763\n99950980 2745\n417095722 2540\n167303264 919\n559358202 8032\n980074733 9688\n708522860 7701\n310816808 3869\n268374020 9370\n987109849 8297\n939193373 8315\n469739607 3738\n915422821 406621\n770040814 9670\n100618150 298\n815321466 7563\n992427936 7331\n760250304 7472\n922339391 2254\n712974510 4553\n209969990 43\n813486412 4851\n253700182 3937\n306427130 5037\n67038179 4135\n47805876 707\n335871240 9881\n487995045 3340\n557659779 9832\n731889470 1433\n584821109 2506\n586453378 1170\n250861167 8771\n223351064 4405\n620462723 6081\n825577316 4850\n399080966 3605\n264025310 8004\n400227694 5108\n838731777 8291\n443941502 2597\n18627547 363\n487710207 9807\n788686347 7789\n73897247 3982\n602571042 7528\n784413349 95582\n670044713 3421\n794698367 7915\n542999138 7768\n786633770 6494\n81542238 2720\n754627733 1847\n473252984 7657\n",
   "200\n211348904 8559\n317621078 9655\n496160959 1077\n672793939 97455\n601915420 5152\n346197283 5352\n637217372 8023\n603366270 6971\n561122489 7070\n372104231 6519\n821009055 729\n917621961 90650\n593782357 3668\n823355949 1096\n631409672 2578\n660053440 8428\n842579879 3237\n375462148 29296\n73476524 4966\n601193857 54392\n827951903 5541\n492134997 6189\n611057590 39246\n281685420 5753\n729669939 764\n765126364 8302\n229386868 4421\n532378442 7025\n388400570 7185\n49218549 2870\n567310733 679\n674042110 63400\n275454207 2641\n46680364 9762\n537543439 100\n387799052 8882\n965244108 8507\n474068579 9112\n420069093 8379\n618072554 9628\n462083633 8262\n603016233 5621\n47805876 707\n275159094 3217\n831616789 1001\n845158607 76242\n781383150 4842\n967068268 5480\n108828788 325\n285077523 3561\n966697008 5681\n692912816 7715\n910831690 8737\n439009014 49391\n977683169 185667\n925259762 250\n548463840 1034\n882890797 7822\n894813302 4040\n769041121 121006\n386721873 7509\n707621274 9219\n25177578 4864\n261940590 8295\n357934425 20239\n334076170 4292\n430938172 863\n699890443 6318\n594598184 5824\n464127139 139\n947288820 9689\n717452068 8076\n53914964 3178\n558905489 1373\n225612419 5963\n845441203 120\n846035721 1212\n338780330 8467\n983107493 6333\n242645785 5994\n922615077 3369\n50736435 4097\n247308480 7770\n90681689 1979\n327801352 27222\n957859677 2506\n665714135 2474\n819752919 759\n618555021 2735\n32814958 2129\n914498477 7367\n524853784 8194\n716881594 1363\n920867484 3682\n20151253 972\n99218082 4678\n28420183 2967\n67720257 5995\n888188829 2391\n615954203 7926\n387664802 9158\n210954003 1342\n872634183 5207\n687643896 3774\n835615466 2813\n435993889 6477\n524896943 9623\n444585027 1063\n785944038 5656\n801566284 6037\n699460686 5257\n489119256 90700\n773702742 9068\n261128441 4094\n577114671 39038\n591594080 2995\n136731117 1895\n763037780 4271\n702229064 2189\n548463840 1034\n360007909 4276\n876023630 52419\n35534560 980\n94405800 4022\n239874120 7436\n484132975 9411\n835603706 2202\n867573043 9832\n596217673 6668\n349302291 82702\n543543845 36790\n63454414 6917\n699770198 67100\n949314087 7431\n413638637 9729\n85065942 6470\n635379817 5490\n852310142 17819\n773829977 65128\n213914409 5084\n672793939 97455\n458854590 74641\n598373273 5132\n484021397 1392\n937214546 7539\n576579457 83710\n577862257 1260\n463188186 40941\n319986942 8751\n490144603 8349\n62117074 2810\n816954022 4819\n875406211 2675\n558783951 219\n171265074 7031\n536142547 1419\n510183568 76560\n323729091 8412\n710460628 1704\n360728400 3258\n746208036 2845\n203904445 5232\n325971851 7888\n326666907 2261\n286834631 929\n371206178 706\n892185867 6514\n910175935 4393\n632803822 40500\n191417638 9812\n814921335 186271\n759460633 8613\n57312007 264\n589273036 9340\n463340708 810\n446147774 1609\n705027810 7090\n270481325 2734\n925515706 1376\n741024259 2393\n737502114 8676\n129145976 4641\n96659618 1766\n886106522 799\n925648555 5209\n692470315 1502\n624023814 26012\n462146088 9524\n958650186 7984\n202350166 8863\n621863375 7562\n259975974 8078\n69297165 9609\n761602080 9921\n519721196 3279\n981492732 1914\n741048314 5760\n954614360 5502\n930057742 2823\n328519021 72\n"
  ],
  "outputs": [
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n",
   "Takahashi\n",
   "Aoki\n"
  ]
 },
 {
  "id": "APPS-3874",
  "question": "Polycarp is a beginner programmer. He is studying how to use a command line.\n\nPolycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.\n\nPolycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.\n\nFormally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.\n\nFor example, the filename pattern \"a?ba?\":  matches filenames \"aabaa\", \"abba.\", \"a.ba9\" and \"a.ba.\";  does not match filenames \"aaba\", \"abaab\", \"aabaaa\" and \"aabaa.\". \n\nHelp Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and m (1 ≤ m ≤ n ≤ 100) — the total number of files and the number of files to be deleted.\n\nThe following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.\n\nThe last line of the input contains m distinct integer numbers in ascending order a_1, a_2, ..., a_{m} (1 ≤ a_{i} ≤ n) — indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.\n\n\n-----Output-----\n\nIf the required pattern exists, print \"Yes\" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.\n\nIf the required pattern doesn't exist, print the only line containing \"No\".\n\n\n-----Examples-----\nInput\n3 2\nab\nac\ncd\n1 2\n\nOutput\nYes\na?\n\nInput\n5 3\ntest\ntezt\ntest.\n.est\ntes.\n1 4 5\n\nOutput\nYes\n?es?\n\nInput\n4 4\na\nb\nc\ndd\n1 2 3 4\n\nOutput\nNo\n\nInput\n6 3\n.svn\n.git\n....\n...\n..\n.\n1 2 3\n\nOutput\nYes\n.???",
  "inputs": [
   "3 2\nab\nac\ncd\n1 2\n",
   "5 3\ntest\ntezt\ntest.\n.est\ntes.\n1 4 5\n",
   "4 4\na\nb\nc\ndd\n1 2 3 4\n",
   "6 3\n.svn\n.git\n....\n...\n..\n.\n1 2 3\n",
   "4 2\n.b\n.c\ndbt\ne.\n2 4\n",
   "27 27\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27\n",
   "27 26\na\nb\nc\nd\nee\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n.\n1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27\n",
   "27 26\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nkq\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n.\n1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27\n",
   "1 1\nuevim.mrr\n1\n",
   "2 1\nkbfyvezmy\nsbfammwcy\n1\n",
   "5 3\nlmljeqklg\nlclydkkxj\nuylscbk.g\neplpqakme\nablibhkfg\n1 3 5\n",
   "5 4\nabacaba\naaaaaaa\naaaaaab\naaaaaac\naaaaaad\n2 3 4 5\n",
   "5 4\nabacaba\naaaaaaa\nbaaaaab\ncaaaaac\ndaaaaad\n2 3 4 5\n",
   "5 5\nabacaba\naaaaaaa\nbaaaaab\ncaaaaac\ndaaaaad\n1 2 3 4 5\n",
   "5 3\nabacaba\naaaaaaa\nbaaaaab\ncaaaaac\ndaaaaad\n2 3 4\n",
   "5 4\naaaaaaa\nbaaaaab\ncaaaaac\ndaaaaad\nabacaba\n1 2 3 4\n",
   "5 3\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\neeeeeeeeee\n1 3 5\n",
   "5 4\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\neeeeeeeeee\n1 3 4 5\n",
   "5 5\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\neeeeeeeeee\n1 2 3 4 5\n",
   "5 4\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\neeeeeeeee\n1 2 3 4\n",
   "5 4\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\neeeeeeeee\ndddddddddd\n1 2 3 5\n",
   "5 4\naaaaaaaaaa\nbbbbbbbbbb\neeeeeeeee\ncccccccccc\ndddddddddd\n1 2 4 5\n",
   "5 4\naaaaaaaaaa\neeeeeeeee\nbbbbbbbbbb\ncccccccccc\ndddddddddd\n1 3 4 5\n",
   "5 4\neeeeeeeee\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\n2 3 4 5\n",
   "2 1\na\nb\n1\n"
  ],
  "outputs": [
   "Yes\na?\n",
   "Yes\n?es?\n",
   "No\n",
   "Yes\n.???\n",
   "No\n",
   "Yes\n?\n",
   "Yes\n?\n",
   "No\n",
   "Yes\nuevim.mrr\n",
   "Yes\nkbfyvezmy\n",
   "Yes\n??l???k?g\n",
   "Yes\naaaaaa?\n",
   "Yes\n?aaaaa?\n",
   "Yes\n??a?a??\n",
   "No\n",
   "Yes\n?aaaaa?\n",
   "No\n",
   "No\n",
   "Yes\n??????????\n",
   "Yes\n??????????\n",
   "Yes\n??????????\n",
   "Yes\n??????????\n",
   "Yes\n??????????\n",
   "Yes\n??????????\n",
   "Yes\na\n"
  ]
 },
 {
  "id": "APPS-3979",
  "question": "You all know that the Library of Bookland is the largest library in the world. There are dozens of thousands of books in the library.\n\nSome long and uninteresting story was removed...\n\nThe alphabet of Bookland is so large that its letters are denoted by positive integers. Each letter can be small or large, the large version of a letter x is denoted by x'. BSCII encoding, which is used everywhere in Bookland, is made in that way so that large letters are presented in the order of the numbers they are denoted by, and small letters are presented in the order of the numbers they are denoted by, but all large letters are before all small letters. For example, the following conditions hold: 2 < 3, 2' < 3', 3' < 2.\n\nA word x_1, x_2, ..., x_{a} is not lexicographically greater than y_1, y_2, ..., y_{b} if one of the two following conditions holds:   a ≤ b and x_1 = y_1, ..., x_{a} = y_{a}, i.e. the first word is the prefix of the second word;  there is a position 1 ≤ j ≤ min(a, b), such that x_1 = y_1, ..., x_{j} - 1 = y_{j} - 1 and x_{j} < y_{j}, i.e. at the first position where the words differ the first word has a smaller letter than the second word has.  \n\nFor example, the word \"3' 7 5\" is before the word \"2 4' 6\" in lexicographical order. It is said that sequence of words is in lexicographical order if each word is not lexicographically greater than the next word in the sequence.\n\nDenis has a sequence of words consisting of small letters only. He wants to change some letters to large (let's call this process a capitalization) in such a way that the sequence of words is in lexicographical order. However, he soon realized that for some reason he can't change a single letter in a single word. He only can choose a letter and change all of its occurrences in all words to large letters. He can perform this operation any number of times with arbitrary letters of Bookland's alphabet.\n\nHelp Denis to choose which letters he needs to capitalize (make large) in order to make the sequence of words lexicographically ordered, or determine that it is impossible.\n\nNote that some words can be equal.\n\n\n-----Input-----\n\nThe first line contains two integers n and m (2 ≤ n ≤ 100 000, 1 ≤ m ≤ 100 000) — the number of words and the number of letters in Bookland's alphabet, respectively. The letters of Bookland's alphabet are denoted by integers from 1 to m.\n\nEach of the next n lines contains a description of one word in format l_{i}, s_{i}, 1, s_{i}, 2, ..., s_{i}, l_{i} (1 ≤ l_{i} ≤ 100 000, 1 ≤ s_{i}, j ≤ m), where l_{i} is the length of the word, and s_{i}, j is the sequence of letters in the word. The words are given in the order Denis has them in the sequence.\n\nIt is guaranteed that the total length of all words is not greater than 100 000.\n\n\n-----Output-----\n\nIn the first line print \"Yes\" (without quotes), if it is possible to capitalize some set of letters in such a way that the sequence of words becomes lexicographically ordered. Otherwise, print \"No\" (without quotes).\n\nIf the required is possible, in the second line print k — the number of letters Denis has to capitalize (make large), and in the third line print k distinct integers — these letters. Note that you don't need to minimize the value k.\n\nYou can print the letters in any order. If there are multiple answers, print any of them.\n\n\n-----Examples-----\nInput\n4 3\n1 2\n1 1\n3 1 3 2\n2 1 1\n\nOutput\nYes\n2\n2 3 \nInput\n6 5\n2 1 2\n2 1 2\n3 1 2 3\n2 1 5\n2 4 4\n2 4 4\n\nOutput\nYes\n0\n\nInput\n4 3\n4 3 2 2 1\n3 1 1 3\n3 2 3 3\n2 3 1\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn the first example after Denis makes letters 2 and 3 large, the sequence looks like the following:  2'  1  1 3' 2'  1 1 \n\nThe condition 2' < 1 holds, so the first word is not lexicographically larger than the second word. The second word is the prefix of the third word, so the are in lexicographical order. As the first letters of the third and the fourth words are the same, and 3' < 1, then the third word is not lexicographically larger than the fourth word.\n\nIn the second example the words are in lexicographical order from the beginning, so Denis can do nothing.\n\nIn the third example there is no set of letters such that if Denis capitalizes them, the sequence becomes lexicographically ordered.",
  "inputs": [
   "4 3\n1 2\n1 1\n3 1 3 2\n2 1 1\n",
   "6 5\n2 1 2\n2 1 2\n3 1 2 3\n2 1 5\n2 4 4\n2 4 4\n",
   "4 3\n4 3 2 2 1\n3 1 1 3\n3 2 3 3\n2 3 1\n",
   "4 4\n3 3 4 1\n4 3 4 2 2\n4 2 1 2 3\n3 4 2 2\n",
   "3 5\n2 1 2\n2 1 5\n2 4 4\n",
   "2 1\n10 1 1 1 1 1 1 1 1 1 1\n25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
   "10 3\n2 3 2\n1 3\n3 1 3 3\n1 2\n2 1 2\n3 2 2 3\n3 3 2 1\n1 2\n2 1 2\n4 1 2 2 3\n",
   "10 3\n2 3 1\n1 2\n1 1\n1 1\n2 3 1\n1 2\n2 3 1\n1 1\n1 3\n2 3 2\n",
   "10 10\n8 1 1 6 10 2 2 9 7\n6 2 7 1 9 5 10\n1 5\n7 3 6 9 6 3 7 6\n10 3 9 10 3 6 7 10 6 9 6\n10 4 4 9 8 2 10 3 6 2 9\n8 4 8 6 4 6 4 8 6\n2 7 5\n6 8 6 2 1 9 8\n3 10 2 10\n",
   "10 10\n8 2 1 3 2 10 5 4 1\n6 2 1 7 5 7 1\n9 2 1 7 5 8 2 8 2 9\n3 2 1 9\n7 2 9 2 2 10 1 7\n10 2 9 2 2 10 1 7 4 1 10\n5 3 5 2 4 4\n7 3 5 9 6 6 5 4\n2 5 6\n6 5 9 8 7 6 9\n",
   "10 4\n2 1 4\n2 1 4\n9 1 4 1 2 3 1 4 4 2\n1 4\n4 4 1 4 3\n7 4 4 4 4 1 4 2\n4 4 2 4 3\n4 2 4 4 4\n1 3\n9 3 3 3 4 2 3 3 2 4\n",
   "3 3\n1 3\n1 2\n1 1\n",
   "2 2\n2 1 2\n1 1\n",
   "2 3\n3 1 2 3\n2 1 2\n",
   "2 100000\n5 1 2 3 1 5\n3 1 2 3\n",
   "4 5\n2 1 5\n2 1 4\n2 2 3\n2 2 5\n",
   "2 100\n3 1 2 3\n1 1\n",
   "5 5\n1 5\n1 4\n1 3\n1 2\n1 1\n",
   "2 1\n2 1 1\n1 1\n",
   "2 3\n2 1 3\n1 1\n",
   "6 100\n1 3\n1 5\n2 7 5\n2 7 2\n3 7 7 2\n3 7 7 3\n"
  ],
  "outputs": [
   "Yes\n2\n2 3 ",
   "Yes\n0\n",
   "No\n",
   "Yes\n1\n3 ",
   "Yes\n0\n",
   "Yes\n0\n",
   "No\n",
   "No\n",
   "Yes\n3\n1 2 5 ",
   "Yes\n0\n",
   "Yes\n2\n1 4 ",
   "No\n",
   "No\n",
   "No\n",
   "No\n",
   "Yes\n2\n3 5 ",
   "No\n",
   "No\n",
   "No\n",
   "No\n",
   "No\n"
  ]
 },
 {
  "id": "APPS-3860",
  "question": "There are $b$ boys and $g$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $n$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them.\n\nOrganizers are preparing red badges for girls and blue ones for boys.\n\nVasya prepared $n+1$ decks of badges. The $i$-th (where $i$ is from $0$ to $n$, inclusive) deck contains $i$ blue badges and $n-i$ red ones. The total number of badges in any deck is exactly $n$.\n\nDetermine the minimum number of decks among these $n+1$ that Vasya should take, so that there will be a suitable deck no matter how many girls and boys there will be among the participants of the tournament.\n\n\n-----Input-----\n\nThe first line contains an integer $b$ ($1 \\le b \\le 300$), the number of boys. \n\nThe second line contains an integer $g$ ($1 \\le g \\le 300$), the number of girls. \n\nThe third line contains an integer $n$ ($1 \\le n \\le b + g$), the number of the board games tournament participants.\n\n\n-----Output-----\n\nOutput the only integer, the minimum number of badge decks that Vasya could take.\n\n\n-----Examples-----\nInput\n5\n6\n3\n\nOutput\n4\n\nInput\n5\n3\n5\n\nOutput\n4\n\n\n\n-----Note-----\n\nIn the first example, each of 4 decks should be taken: (0 blue, 3 red), (1 blue, 2 red), (2 blue, 1 red), (3 blue, 0 red).\n\nIn the second example, 4 decks should be taken: (2 blue, 3 red), (3 blue, 2 red), (4 blue, 1 red), (5 blue, 0 red). Piles (0 blue, 5 red) and (1 blue, 4 red) can not be used.",
  "inputs": [
   "5\n6\n3\n",
   "5\n3\n5\n",
   "1\n200\n33\n",
   "100\n200\n150\n",
   "123\n55\n100\n",
   "300\n300\n600\n",
   "1\n1\n1\n",
   "100\n200\n250\n",
   "100\n200\n300\n",
   "123\n222\n250\n",
   "300\n300\n1\n",
   "300\n299\n300\n",
   "1\n1\n2\n",
   "300\n1\n45\n",
   "199\n199\n199\n",
   "297\n297\n298\n",
   "299\n259\n300\n",
   "288\n188\n300\n",
   "5\n299\n4\n",
   "199\n131\n45\n",
   "50\n100\n120\n",
   "3\n3\n4\n",
   "4\n4\n5\n",
   "4\n4\n7\n",
   "3\n3\n5\n"
  ],
  "outputs": [
   "4\n",
   "4\n",
   "2\n",
   "101\n",
   "56\n",
   "1\n",
   "2\n",
   "51\n",
   "1\n",
   "96\n",
   "2\n",
   "300\n",
   "1\n",
   "2\n",
   "200\n",
   "297\n",
   "259\n",
   "177\n",
   "5\n",
   "46\n",
   "31\n",
   "3\n",
   "4\n",
   "2\n",
   "2\n"
  ]
 },
 {
  "id": "APPS-3999",
  "question": "AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 between 999. The top-left, top-right, bottom-right and bottom-left corner of the tile with the number i are painted in color C_{i,0}, C_{i,1}, C_{i,2} and C_{i,3}, respectively, when seen in the direction of the number written on the tile (See Figure 1).\nFigure 1: The correspondence between the colors of a tile and the input\nAtCoDeer is constructing a cube using six of these tiles, under the following conditions:\n - For each tile, the side with the number must face outward.\n - For each vertex of the cube, the three corners of the tiles that forms it must all be painted in the same color.\nHelp him by finding the number of the different cubes that can be constructed under the conditions.\nSince each tile has a number written on it, two cubes are considered different if the set of the used tiles are different, or the tiles are used in different directions, even if the formation of the colors are the same. (Each tile can be used in one of the four directions, obtained by 90° rotations.) Two cubes are considered the same only if rotating one in the three dimensional space can obtain an exact copy of the other, including the directions of the tiles.\nFigure 2: The four directions of a tile\n\n-----Constraints-----\n - 6≦N≦400\n - 0≦C_{i,j}≦999 (1≦i≦N , 0≦j≦3)\n\n-----Input-----\nThe input is given from Standard Input in the following format:\nN\nC_{1,0} C_{1,1} C_{1,2} C_{1,3}\nC_{2,0} C_{2,1} C_{2,2} C_{2,3}\n:\nC_{N,0} C_{N,1} C_{N,2} C_{N,3}\n\n-----Output-----\nPrint the number of the different cubes that can be constructed under the conditions.\n\n-----Sample Input-----\n6\n0 1 2 3\n0 4 6 1\n1 6 7 2\n2 7 5 3\n6 4 5 7\n4 0 3 5\n\n-----Sample Output-----\n1\n\nThe cube below can be constructed.",
  "inputs": [
   "6\n0 1 2 3\n0 4 6 1\n1 6 7 2\n2 7 5 3\n6 4 5 7\n4 0 3 5\n",
   "8\n0 0 0 0\n0 0 1 1\n0 1 0 1\n0 1 1 0\n1 0 0 1\n1 0 1 0\n1 1 0 0\n1 1 1 1\n",
   "6\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n",
   "400\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0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 6\n7 0 1 0\n1 0 7 0\n9 8 7 6\n2 1 5 9\n9 3 4 8\n7 7 6 7\n1 7 7 2\n1 1 4 3\n4 5 3 1\n0 0 8 1\n7 7 0 7\n8 8 0 2\n3 2 4 5\n1 7 9 6\n4 9 0 9\n6 2 4 0\n1 6 8 4\n6 4 5 6\n3 6 4 8\n6 1 3 2\n2 8 8 8\n3 1 2 6\n1 0 1 3\n3 2 7 8\n6 5 4 8\n1 5 6 3\n1 1 1 3\n",
   "400\n36 10 16 57\n95 87 60 30\n79 85 43 46\n0 79 14 89\n50 86 24 58\n48 98 12 57\n61 43 19 33\n17 90 5 49\n64 14 26 74\n76 80 82 47\n61 27 2 70\n54 95 43 31\n48 13 60 80\n54 0 59 99\n76 55 37 23\n36 19 79 66\n32 12 38 80\n72 5 68 80\n99 85 73 7\n13 61 91 37\n42 16 57 3\n57 5 87 95\n98 64 29 93\n75 20 95 38\n35 65 28 3\n19 99 67 47\n41 31 14 31\n20 2 15 72\n46 23 10 94\n50 65 20 59\n97 63 41 34\n32 53 13 96\n8 92 53 79\n22 13 34 90\n71 40 43 91\n3 68 56 42\n19 3 11 39\n21 63 74 57\n39 27 63 71\n55 69 4 8\n53 34 88 67\n41 13 72 52\n73 52 99 85\n35 32 39 1\n12 83 37 43\n96 77 60 88\n66 72 43 12\n29 70 69 19\n57 34 29 87\n31 74 36 77\n55 55 82 25\n52 74 75 72\n67 20 70 30\n50 54 3 36\n4 47 67 76\n97 42 44 11\n60 84 49 97\n37 27 39 53\n29 87 53 47\n81 26 78 11\n71 49 85 39\n65 93 83 21\n68 64 61 4\n44 7 73 94\n13 81 90 51\n78 22 77 16\n20 89 39 66\n23 76 97 54\n68 66 27 31\n17 68 44 43\n49 37 72 40\n34 7 68 94\n2 76 82 9\n79 61 85 38\n10 3 96 63\n37 83 60 45\n30 64 46 21\n3 25 21 11\n53 80 56 15\n42 83 32 93\n26 62 45 73\n59 13 85 96\n48 12 85 38\n36 97 27 57\n36 58 5 98\n51 25 0 4\n7 1 18 86\n28 51 10 70\n73 98 53 9\n15 63 51 61\n2 53 1 26\n27 28 62 80\n68 25 88 98\n68 32 7 45\n83 51 77 77\n49 71 74 13\n91 8 16 57\n2 65 72 20\n17 53 32 36\n67 34 60 8\n37 16 55 68\n27 26 75 92\n85 86 5 31\n61 15 68 19\n96 33 29 42\n65 96 76 79\n67 24 42 12\n12 9 46 4\n11 52 15 98\n83 19 75 32\n44 67 99 65\n23 75 39 94\n48 0 61 96\n12 20 2 82\n77 87 52 93\n32 87 80 0\n6 72 67 29\n36 91 1 58\n34 89 98 30\n36 15 0 44\n83 85 27 87\n50 80 7 15\n76 38 1 72\n82 34 69 24\n70 28 60 84\n68 42 55 44\n58 28 54 84\n31 22 43 72\n93 17 71 78\n55 74 32 95\n62 7 37 92\n12 27 19 25\n95 81 72 25\n68 43 66 48\n76 41 43 57\n85 54 4 98\n94 52 93 74\n0 97 66 19\n17 73 0 91\n46 58 52 65\n22 42 29 81\n59 28 62 68\n24 56 86 25\n53 69 87 66\n94 1 49 7\n29 64 96 2\n31 85 31 74\n17 67 37 66\n65 11 86 59\n86 16 74 86\n82 39 49 13\n16 16 71 52\n17 24 80 48\n25 13 76 44\n14 77 25 8\n41 29 46 11\n77 61 76 16\n12 70 99 37\n10 1 59 13\n41 64 45 9\n88 82 9 78\n84 66 80 69\n16 16 14 75\n25 90 46 8\n50 27 54 24\n35 63 46 37\n40 51 41 93\n73 15 49 63\n13 50 45 20\n83 0 94 45\n3 87 31 96\n90 13 38 21\n40 42 0 78\n3 55 80 95\n56 31 93 88\n80 82 15 60\n9 28 71 28\n54 55 78 73\n86 5 63 38\n87 93 22 42\n88 5 38 75\n53 90 8 57\n7 72 54 67\n72 97 70 7\n64 45 11 51\n36 43 30 19\n32 3 94 59\n97 60 54 92\n48 77 65 71\n52 45 8 57\n55 31 80 37\n84 64 63 0\n67 32 25 36\n10 32 92 17\n59 88 65 4\n35 0 50 10\n45 93 4 89\n53 1 14 30\n37 59 8 63\n34 70 30 19\n44 90 29 29\n91 86 41 38\n2 24 42 88\n22 42 65 19\n8 41 67 46\n8 81 20 52\n77 1 17 93\n34 25 11 89\n52 38 56 91\n12 13 13 2\n56 0 95 85\n1 30 61 37\n35 90 90 6\n0 88 54 39\n76 64 43 86\n89 48 66 16\n92 60 73 77\n20 5 88 13\n47 11 84 84\n61 20 76 60\n55 99 26 48\n81 26 38 3\n16 28 30 95\n91 62 50 14\n34 65 97 28\n44 77 89 64\n30 58 59 72\n65 28 58 38\n61 97 58 69\n21 58 22 37\n10 30 3 64\n47 77 28 2\n0 48 74 64\n95 83 86 37\n61 4 10 82\n86 38 65 80\n79 87 78 9\n65 58 47 3\n51 73 93 17\n14 47 96 84\n52 42 10 65\n38 81 45 10\n48 61 44 50\n43 62 23 43\n11 69 87 95\n63 4 73 95\n81 18 60 57\n15 65 50 56\n28 30 40 74\n25 12 98 2\n83 38 50 55\n49 11 41 50\n39 92 92 68\n99 85 68 8\n13 56 21 36\n47 7 2 10\n74 21 21 12\n75 77 67 45\n42 2 90 18\n8 27 15 12\n25 75 49 75\n28 97 28 30\n4 63 63 60\n93 1 51 31\n60 94 64 98\n56 50 74 91\n61 2 42 71\n11 12 53 52\n24 3 90 46\n95 12 4 45\n24 72 10 3\n62 83 62 57\n16 81 29 89\n1 12 96 76\n12 81 62 37\n6 24 6 43\n59 39 92 87\n95 46 61 50\n23 87 34 93\n77 89 67 14\n32 39 16 29\n94 27 89 32\n67 27 28 1\n54 73 28 58\n0 75 38 42\n97 23 95 35\n31 58 20 36\n15 51 57 61\n87 7 62 5\n38 67 41 16\n18 5 94 19\n51 32 13 70\n98 80 24 56\n37 55 21 90\n98 19 59 98\n71 40 38 30\n81 37 90 30\n82 39 24 19\n17 11 91 66\n92 97 1 65\n32 1 91 77\n70 34 37 66\n27 66 71 99\n30 42 52 54\n21 86 16 8\n33 73 1 5\n92 23 95 99\n66 60 86 73\n68 63 22 9\n76 99 49 43\n29 90 37 21\n68 95 56 3\n37 6 52 54\n87 87 89 74\n31 95 15 26\n68 37 86 93\n65 53 57 67\n32 96 66 93\n6 75 63 42\n16 49 90 3\n0 55 75 29\n42 87 92 54\n6 91 62 58\n3 52 35 77\n91 71 4 92\n57 23 67 20\n73 86 64 6\n86 42 89 20\n46 28 24 33\n63 31 61 65\n21 6 64 80\n70 85 78 94\n13 18 12 43\n36 22 94 45\n65 78 53 87\n23 63 71 64\n19 66 40 9\n53 77 50 28\n25 44 58 68\n10 11 90 22\n69 34 52 57\n45 43 37 42\n44 91 96 54\n71 0 42 18\n94 63 9 22\n62 59 37 30\n20 10 15 1\n14 20 94 31\n74 29 56 50\n55 19 21 41\n33 66 84 50\n49 5 83 42\n69 10 13 28\n98 26 39 23\n79 31 7 76\n23 22 97 88\n8 21 5 66\n19 6 2 49\n4 98 65 73\n13 22 9 33\n7 52 35 22\n54 26 52 15\n55 27 50 53\n44 75 0 60\n91 70 89 88\n0 84 8 74\n89 8 35 60\n13 47 50 25\n88 12 56 45\n45 91 71 18\n2 63 89 91\n62 9 3 46\n87 99 22 28\n34 73 34 44\n88 7 11 83\n30 52 68 0\n92 27 22 45\n40 33 53 88\n89 58 19 47\n73 65 33 31\n40 28 92 40\n83 61 89 52\n20 36 52 93\n30 12 84 17\n23 32 99 9\n47 27 42 78\n77 21 20 40\n96 87 32 48\n50 94 93 2\n56 55 57 92\n15 66 78 27\n89 45 46 76\n6 63 95 2\n37 99 46 42\n32 87 64 39\n15 71 54 46\n69 80 31 39\n0 73 38 6\n76 61 50 68\n70 17 57 89\n",
   "41\n68 71 90 75\n77 90 56 85\n68 68 11 29\n92 68 50 78\n70 50 36 25\n51 37 51 42\n71 58 34 65\n95 28 91 61\n16 58 3 65\n90 85 51 66\n55 63 56 97\n86 37 55 65\n64 16 27 41\n10 9 88 40\n13 14 57 2\n86 50 26 80\n30 24 32 15\n38 23 19 54\n97 31 5 6\n27 3 17 61\n7 53 79 23\n13 14 32 35\n65 19 77 74\n79 77 56 9\n91 88 60 38\n21 24 59 98\n31 45 3 74\n1 98 72 0\n78 48 28 44\n61 61 49 8\n97 39 41 2\n21 19 65 41\n37 84 28 26\n51 61 74 13\n76 72 33 28\n54 96 80 88\n25 62 35 88\n33 56 4 39\n59 15 91 38\n30 99 86 2\n66 57 47 28\n",
   "400\n820 368 490 712\n16 813 235 455\n322 838 626 969\n849 723 123 271\n787 925 469 271\n987 610 339 690\n464 865 469 675\n650 254 781 510\n679 19 798 682\n588 228 767 900\n223 661 908 122\n817 74 597 801\n881 323 328 164\n843 409 42 465\n704 705 803 681\n703 997 160 748\n313 145 425 247\n738 249 74 379\n852 588 447 275\n21 268 17 442\n856 541 365 14\n921 16 572 637\n578 908 981 282\n155 391 150 428\n382 662 745 484\n616 943 723 945\n852 527 352 209\n585 957 978 886\n652 90 641 722\n80 571 900 377\n921 316 949 626\n417 723 75 497\n466 638 145 812\n314 858 916 648\n836 626 393 199\n994 592 5 248\n224 843 758 620\n485 709 526 568\n723 383 625 972\n461 587 76 358\n816 942 933 892\n26 40 297 685\n943 393 472 530\n35 962 109 574\n90 293 833 38\n498 898 992 567\n34 168 27 812\n708 676 732 81\n557 760 417 903\n750 851 671 219\n619 617 471 373\n217 687 710 746\n396 85 327 751\n509 144 131 707\n755 275 793 903\n649 561 216 348\n861 690 112 17\n673 64 265 88\n802 300 644 252\n278 258 109 282\n899 46 786 752\n10 441 637 254\n298 956 645 328\n240 511 115 909\n52 975 128 775\n696 738 620 647\n337 104 569 468\n400 336 78 64\n410 396 624 47\n179 250 434 301\n826 391 5 83\n86 10 138 990\n798 91 28 76\n125 86 796 627\n332 800 812 752\n394 533 60 905\n135 915 931 648\n558 254 637 812\n672 673 443 269\n742 382 969 396\n286 946 408 245\n726 240 484 362\n847 176 447 645\n945 156 436 273\n436 175 272 574\n814 194 51 895\n217 484 37 41\n404 990 635 219\n913 424 472 357\n831 3 920 494\n70 660 584 638\n71 498 393 268\n662 900 796 197\n120 634 471 698\n406 726 566 876\n956 134 452 343\n531 730 320 584\n562 452 53 876\n692 41 50 559\n570 674 104 878\n217 167 450 753\n158 673 822 825\n798 594 201 945\n683 580 946 804\n152 890 364 507\n13 983 623 841\n606 609 888 501\n694 9 437 891\n57 899 109 552\n390 908 876 559\n715 492 452 45\n820 74 230 349\n451 358 568 737\n883 335 33 303\n504 754 912 747\n325 83 43 510\n953 795 443 939\n820 503 436 722\n747 344 890 99\n67 92 838 856\n842 121 281 327\n480 233 192 763\n149 511 709 62\n45 508 686 613\n182 205 758 264\n90 733 50 740\n248 371 190 399\n940 688 302 128\n935 447 369 560\n425 649 143 617\n555 380 59 401\n985 367 171 834\n572 597 884 706\n846 547 963 187\n294 871 494 238\n660 264 713 16\n279 12 357 641\n529 922 371 420\n828 341 566 96\n277 905 877 595\n383 45 368 102\n883 173 818 49\n235 106 189 219\n598 936 916 37\n133 253 865 692\n860 617 191 114\n573 542 881 520\n886 709 361 474\n434 138 670 471\n45 558 252 651\n393 127 15 555\n670 286 858 732\n167 580 49 208\n687 474 352 550\n961 780 962 461\n495 848 323 356\n827 305 841 353\n265 819 69 957\n725 426 592 745\n345 44 984 927\n7 159 994 382\n477 448 1 443\n118 353 156 681\n908 854 470 742\n20 685 607 849\n570 151 232 43\n459 391 508 761\n538 822 25 211\n138 617 454 661\n794 960 695 351\n654 67 563 490\n138 547 215 658\n873 890 411 411\n252 288 570 137\n319 427 183 280\n237 370 2 196\n59 22 610 590\n178 413 309 236\n334 549 155 900\n76 690 153 445\n216 420 681 41\n172 768 646 771\n804 456 517 289\n494 218 159 286\n312 258 651 55\n810 573 680 823\n186 419 296 794\n502 96 785 658\n539 335 301 193\n333 867 753 724\n520 388 978 209\n906 26 755 997\n891 257 235 467\n749 138 516 372\n742 833 782 576\n660 728 426 679\n240 455 763 127\n315 414 422 858\n205 258 698 643\n868 39 554 780\n937 224 792 927\n479 544 332 240\n725 60 113 235\n539 775 136 679\n449 873 359 670\n498 893 297 496\n55 94 601 739\n616 517 409 289\n110 122 412 102\n212 20 700 677\n164 246 213 942\n70 977 361 517\n226 176 405 978\n847 860 528 753\n916 236 835 958\n875 56 4 959\n590 562 269 21\n609 738 777 951\n303 813 623 253\n201 313 879 887\n473 984 433 752\n668 518 333 250\n942 8 52 743\n512 291 934 513\n172 734 165 175\n33 294 663 412\n698 36 561 365\n72 428 118 31\n848 13 727 563\n696 496 924 992\n602 735 120 827\n43 307 187 364\n525 9 90 464\n560 99 393 927\n0 959 208 858\n824 6 427 123\n692 635 939 232\n436 965 658 461\n684 235 204 565\n848 148 480 765\n949 720 534 117\n651 454 355 451\n167 90 280 86\n748 810 57 397\n969 726 273 146\n606 354 890 886\n992 594 458 201\n476 609 289 446\n704 965 703 673\n757 418 99 198\n337 593 61 935\n537 749 165 170\n27 603 413 909\n721 419 65 831\n865 759 855 740\n714 319 921 940\n914 758 672 592\n42 68 394 2\n859 41 660 697\n705 659 410 446\n85 596 243 470\n417 908 155 252\n573 134 920 929\n510 153 157 163\n374 973 660 111\n295 608 622 165\n744 773 903 719\n930 983 629 53\n372 535 847 112\n395 752 683 472\n174 579 943 389\n493 996 760 143\n417 104 89 946\n654 865 779 137\n214 872 811 589\n799 190 810 891\n564 583 414 912\n978 500 693 329\n369 51 817 779\n98 724 615 491\n623 818 914 316\n517 589 325 867\n783 640 301 216\n181 308 436 187\n945 856 66 481\n58 51 470 290\n465 888 827 295\n649 941 789 301\n404 616 931 745\n272 773 62 159\n736 440 927 19\n766 140 784 515\n799 695 840 767\n839 914 386 686\n220 392 335 910\n638 234 871 264\n27 940 303 717\n617 496 285 873\n677 341 567 851\n304 547 937 389\n1 302 293 775\n486 5 444 274\n964 862 971 884\n70 887 825 807\n865 91 44 405\n830 184 60 605\n41 73 503 731\n583 517 811 759\n436 211 11 764\n106 151 936 907\n734 518 537 75\n892 410 470 31\n730 650 29 661\n386 986 247 559\n113 490 141 71\n749 189 436 667\n300 592 703 131\n639 13 348 123\n205 476 703 177\n436 573 594 845\n82 532 486 320\n514 113 491 26\n114 451 659 844\n216 672 997 734\n893 43 374 119\n194 3 761 727\n279 660 7 154\n931 157 578 547\n677 21 611 642\n176 914 587 932\n902 743 479 813\n419 626 556 997\n354 847 354 396\n174 156 294 707\n6 827 479 137\n627 21 297 262\n198 841 416 840\n338 697 52 575\n473 381 595 247\n755 470 301 450\n409 377 257 687\n911 61 380 547\n223 59 441 234\n874 122 300 338\n106 980 945 797\n532 281 786 145\n649 798 501 989\n259 417 340 234\n124 83 77 803\n33 962 962 403\n934 250 115 202\n212 448 911 427\n637 19 722 989\n128 767 752 964\n200 615 88 67\n391 182 331 889\n551 795 628 85\n393 174 834 390\n399 883 168 676\n483 122 901 125\n315 321 623 429\n380 271 811 677\n947 597 895 718\n635 411 841 826\n328 563 824 184\n82 958 824 202\n453 690 467 508\n197 261 683 868\n911 449 36 976\n163 580 398 464\n278 338 416 537\n19 241 752 59\n985 561 895 72\n304 462 137 538\n109 651 154 15\n549 645 940 219\n623 673 277 211\n137 75 821 81\n764 692 262 345\n100 127 588 495\n263 952 740 578\n224 729 760 809\n219 235 896 849\n880 549 261 712\n397 692 998 673\n147 568 54 748\n203 918 741 289\n457 551 954 601\n798 164 674 849\n596 116 634 716\n531 332 705 204\n665 98 265 949\n13 991 372 886\n668 814 730 45\n861 628 185 901\n711 350 118 471\n810 898 623 106\n211 419 107 280\n49 900 177 63\n772 960 549 40\n",
   "210\n689 359 920 186\n56 120 95 811\n93 746 752 471\n235 363 799 420\n230 856 646 537\n982 559 136 886\n347 579 605 378\n84 755 279 48\n962 704 324 424\n321 200 412 533\n383 780 498 744\n253 298 608 416\n883 808 179 371\n855 238 37 510\n677 582 329 197\n179 963 961 272\n363 971 899 843\n52 715 778 840\n690 189 337 898\n49 128 18 896\n713 245 77 197\n507 617 972 184\n2 740 163 757\n373 436 373 399\n481 294 25 216\n43 419 195 622\n834 891 671 620\n763 601 537 242\n934 747 96 570\n118 692 408 489\n502 535 55 893\n487 394 607 665\n470 21 370 274\n378 373 476 981\n395 378 810 776\n606 369 184 490\n725 967 72 415\n539 291 911 83\n45 341 945 514\n772 609 189 642\n207 171 419 774\n710 798 977 321\n337 757 669 619\n519 116 829 98\n754 620 362 991\n503 185 459 324\n195 874 998 872\n753 597 945 639\n449 372 759 240\n34 256 366 764\n152 440 860 408\n297 502 50 23\n433 14 81 640\n477 724 401 519\n652 689 905 58\n578 834 744 370\n878 837 194 452\n251 72 990 883\n756 432 76 764\n625 170 668 158\n270 738 433 868\n106 622 173 184\n948 302 734 197\n706 891 142 969\n684 985 40 837\n237 538 334 875\n737 616 40 387\n874 462 687 946\n605 220 599 751\n353 501 595 699\n280 758 794 677\n405 6 375 855\n445 812 710 144\n403 834 498 750\n172 588 148 560\n457 949 774 142\n442 406 302 326\n119 355 398 500\n890 525 688 909\n640 621 966 352\n71 275 479 312\n401 260 526 738\n847 729 341 376\n297 82 287 160\n609 486 346 813\n727 125 571 376\n295 373 276 482\n63 901 792 112\n44 162 839 795\n981 715 277 290\n887 451 69 575\n207 850 884 668\n718 80 536 16\n830 128 934 113\n115 700 642 247\n397 683 593 987\n850 812 331 498\n96 845 869 651\n136 700 906 624\n734 897 690 604\n861 63 634 906\n719 542 939 325\n930 238 263 745\n631 689 405 117\n636 805 718 108\n584 132 472 975\n758 106 192 416\n507 115 804 861\n642 327 694 328\n167 692 237 87\n153 925 830 620\n600 428 88 595\n589 369 292 155\n33 366 387 827\n838 137 81 627\n994 644 952 732\n705 245 664 53\n434 325 289 571\n682 400 331 260\n269 760 661 456\n203 109 114 228\n862 293 953 708\n434 676 763 28\n742 528 368 76\n191 52 194 198\n579 279 979 917\n466 400 971 244\n217 257 497 64\n601 397 434 930\n548 646 312 717\n511 487 594 944\n643 595 401 89\n742 121 306 879\n110 197 271 506\n790 459 808 201\n417 10 80 599\n810 27 706 274\n926 117 538 362\n98 335 48 955\n846 753 127 847\n499 39 83 747\n584 634 281 228\n688 789 945 286\n216 697 750 345\n748 894 478 880\n121 350 220 223\n893 343 187 856\n859 582 789 914\n474 802 690 359\n133 276 220 993\n870 393 255 960\n371 793 126 730\n34 975 872 496\n553 773 578 40\n886 364 934 460\n261 861 609 671\n728 295 249 15\n648 365 685 804\n466 971 488 739\n709 229 573 631\n336 404 846 197\n680 558 967 842\n175 177 573 355\n888 44 5 536\n167 345 807 247\n598 123 648 497\n457 400 263 594\n123 427 823 610\n138 681 843 979\n69 717 761 143\n214 754 469 856\n978 253 246 83\n612 717 261 18\n498 208 681 460\n56 763 208 683\n729 485 216 369\n740 664 876 256\n946 30 594 5\n381 412 888 864\n260 341 159 451\n316 510 216 164\n553 225 811 121\n874 552 927 719\n2 328 636 759\n626 240 427 630\n971 52 63 343\n906 266 997 559\n133 656 918 780\n801 720 101 363\n822 738 796 253\n346 956 697 277\n138 248 950 672\n472 530 230 226\n205 605 195 153\n303 633 821 112\n774 978 885 298\n625 800 775 689\n38 751 374 562\n942 3 825 839\n334 993 723 961\n410 196 177 407\n748 451 780 935\n458 676 574 536\n990 519 593 650\n286 969 539 834\n412 220 238 174\n328 455 667 314\n50 775 911 44\n692 690 750 586\n947 347 300 494\n",
   "400\n204 243 638 375\n259 713 936 9\n960 266 822 684\n734 704 157 724\n371 463 724 179\n553 187 897 123\n761 414 751 489\n984 789 988 13\n705 467 462 856\n40 316 937 465\n122 635 567 685\n60 504 533 47\n8 655 874 986\n756 403 985 50\n338 813 345 149\n212 888 925 73\n328 752 339 630\n376 597 160 628\n457 535 190 465\n793 186 338 753\n235 416 81 530\n582 124 976 467\n325 146 641 522\n624 983 847 59\n824 318 690 944\n731 412 500 454\n898 594 647 813\n446 171 66 279\n580 652 331 348\n921 105 188 767\n390 481 212 205\n277 357 948 52\n23 756 567 830\n936 214 427 220\n203 734 36 336\n663 46 473 984\n498 704 217 779\n933 875 157 24\n365 747 183 295\n11 460 655 977\n158 943 248 191\n426 838 132 426\n284 493 627 436\n786 469 953 690\n917 98 398 325\n606 470 836 939\n89 809 997 837\n496 266 474 190\n630 420 140 403\n237 913 783 911\n267 859 76 857\n36 209 656 145\n559 424 751 83\n914 27 561 296\n452 828 831 200\n494 856 377 786\n812 846 280 702\n958 599 459 58\n426 168 525 878\n857 388 396 999\n58 719 473 348\n961 132 915 41\n795 123 712 944\n712 754 751 18\n911 883 593 805\n744 17 379 495\n767 875 972 529\n981 77 493 720\n192 441 742 169\n26 339 810 534\n478 970 531 111\n911 961 417 892\n71 191 739 390\n188 638 599 168\n739 990 153 823\n48 99 614 579\n76 755 761 782\n357 976 605 33\n277 236 121 825\n59 843 837 862\n841 204 207 51\n936 721 655 375\n600 930 688 45\n118 985 712 83\n917 961 375 336\n628 96 15 275\n284 756 688 910\n906 14 320 429\n642 437 677 106\n621 751 216 223\n126 506 380 345\n648 879 244 443\n359 218 771 664\n919 863 766 207\n754 2 707 568\n389 629 515 952\n40 303 222 783\n373 877 9 463\n749 817 956 180\n647 947 730 926\n898 186 925 373\n99 383 897 794\n186 384 341 493\n90 196 347 6\n327 771 543 799\n607 674 383 638\n297 493 809 779\n60 520 487 674\n464 191 965 428\n732 452 976 472\n305 919 24 202\n342 960 530 141\n531 249 998 399\n802 168 397 899\n885 494 533 112\n239 10 319 754\n534 568 825 139\n293 977 652 877\n116 596 538 814\n113 428 301 168\n571 558 533 26\n558 434 210 191\n430 700 877 48\n96 815 56 484\n405 797 313 494\n955 659 328 675\n23 151 231 219\n952 430 106 689\n862 154 668 795\n26 385 777 781\n855 730 667 77\n605 898 214 316\n635 348 807 94\n948 611 753 170\n747 483 271 187\n977 853 162 331\n419 462 597 81\n853 950 646 143\n816 701 923 675\n633 255 27 278\n727 517 849 461\n983 862 452 133\n590 909 327 11\n541 462 796 805\n410 442 421 181\n919 377 950 590\n452 252 255 698\n95 386 460 581\n518 897 538 269\n765 17 442 823\n926 402 486 670\n374 934 616 628\n135 519 659 605\n560 949 774 78\n43 365 776 166\n580 2 148 360\n283 479 79 994\n715 507 83 43\n340 206 845 554\n491 366 37 163\n740 197 223 184\n509 18 618 36\n760 169 39 710\n344 203 114 11\n735 995 106 795\n747 31 941 724\n100 970 585 757\n211 582 754 525\n488 886 56 899\n949 518 792 382\n479 98 102 58\n693 131 170 812\n196 147 510 610\n393 732 960 26\n178 69 856 997\n974 482 33 94\n533 232 346 428\n171 125 519 490\n827 282 959 118\n149 309 884 388\n517 346 274 575\n886 935 735 674\n455 207 220 729\n922 183 650 458\n827 327 292 758\n820 286 500 308\n530 436 601 832\n99 553 607 367\n751 305 550 218\n180 315 351 534\n706 253 451 485\n662 84 54 848\n684 719 50 210\n810 988 229 581\n632 739 738 219\n312 316 174 628\n323 333 320 63\n963 92 96 142\n832 852 912 125\n26 167 860 363\n275 28 414 992\n730 947 710 331\n620 391 324 741\n546 709 999 732\n195 817 599 735\n400 288 928 707\n526 386 671 107\n363 506 51 988\n18 127 931 831\n80 928 798 972\n3 312 852 350\n512 998 809 40\n456 329 21 542\n879 893 450 820\n827 267 937 812\n913 573 950 778\n444 576 529 724\n581 304 850 320\n968 293 812 775\n509 272 569 92\n142 734 378 208\n50 727 330 933\n438 88 599 319\n582 916 806 155\n973 133 470 678\n612 927 155 713\n472 847 838 899\n794 405 334 180\n510 757 255 657\n57 938 282 283\n345 628 573 272\n406 383 379 927\n343 868 334 600\n547 22 250 876\n656 880 614 337\n770 406 161 764\n128 733 152 36\n204 924 672 265\n80 16 649 701\n533 348 717 982\n353 134 417 714\n286 532 580 630\n856 520 357 987\n72 703 978 895\n93 898 900 730\n728 995 908 531\n858 882 814 49\n840 794 302 40\n452 298 501 991\n824 727 3 947\n603 522 750 496\n903 814 666 717\n377 97 129 615\n67 518 349 925\n268 38 437 954\n647 926 294 78\n747 886 125 109\n632 850 781 5\n613 36 958 996\n710 947 647 78\n532 817 443 739\n809 566 885 992\n96 506 661 562\n974 347 663 436\n103 68 355 801\n74 12 7 772\n858 87 303 702\n485 482 991 884\n123 295 833 597\n489 133 655 621\n217 389 782 208\n583 980 744 468\n14 455 520 761\n706 561 395 978\n477 840 619 887\n985 134 245 622\n411 564 863 757\n486 579 399 264\n867 255 8 851\n835 377 352 388\n568 163 442 822\n866 278 390 439\n693 939 763 547\n268 236 667 344\n643 714 860 603\n7 271 326 56\n267 790 66 770\n851 854 900 222\n782 765 172 698\n453 79 554 297\n405 60 995 921\n443 801 495 505\n434 37 5 778\n267 156 817 542\n221 399 716 869\n780 981 102 103\n601 286 995 431\n39 800 433 447\n467 468 756 547\n404 28 39 256\n682 426 600 612\n595 844 703 625\n954 426 837 647\n486 774 873 227\n614 367 408 877\n931 283 892 561\n529 55 319 645\n293 195 253 257\n451 783 670 783\n300 430 48 559\n181 707 149 485\n496 452 654 322\n82 109 3 194\n0 937 199 478\n83 636 178 987\n294 926 730 331\n804 235 918 446\n720 124 749 592\n178 550 722 411\n544 896 375 478\n24 395 267 512\n401 631 817 483\n332 94 666 556\n197 308 800 749\n777 413 496 899\n965 308 903 105\n540 834 341 405\n125 292 471 159\n980 835 330 689\n285 662 977 786\n331 710 78 294\n934 200 361 895\n398 754 741 245\n475 568 774 588\n787 247 326 254\n147 143 963 106\n15 4 113 647\n352 51 391 63\n89 146 911 513\n36 882 479 508\n190 28 68 429\n507 32 47 387\n652 669 142 785\n769 286 60 259\n655 729 274 103\n809 330 803 980\n182 720 524 431\n748 451 432 440\n392 527 283 857\n639 995 406 315\n639 511 394 478\n638 509 135 872\n244 305 559 4\n530 4 421 78\n679 82 636 578\n728 756 887 84\n749 48 778 407\n221 837 851 435\n449 502 541 169\n536 0 471 698\n408 417 992 646\n496 668 632 55\n272 97 40 193\n882 874 904 70\n266 447 481 401\n776 108 275 656\n584 950 471 648\n57 109 829 184\n698 891 386 682\n974 844 121 622\n944 525 347 353\n88 940 814 337\n319 360 247 307\n794 163 845 288\n115 48 544 182\n814 714 605 45\n85 760 950 368\n332 886 542 344\n337 566 867 825\n26 140 763 347\n13 781 692 444\n789 472 413 816\n27 252 755 843\n476 995 24 467\n203 90 46 55\n482 474 362 36\n155 794 132 953\n404 229 580 962\n507 394 356 361\n632 707 874 593\n856 269 374 608\n905 115 814 558\n75 939 103 18\n362 922 463 325\n79 825 704 443\n76 225 512 663\n890 187 530 877\n316 726 487 537\n469 576 191 816\n351 760 469 285\n",
   "400\n196 345 527 695\n685 207 136 831\n303 497 409 762\n464 670 120 403\n867 799 702 490\n986 9 287 852\n519 89 617 973\n291 551 957 275\n329 210 75 744\n685 560 225 510\n568 429 313 112\n94 659 30 204\n51 891 791 326\n890 977 807 600\n203 468 753 791\n738 279 376 58\n377 694 954 955\n436 875 436 104\n942 118 5 449\n927 356 825 170\n835 99 196 254\n461 638 726 368\n237 215 348 307\n9 981 5 586\n335 779 218 127\n515 466 155 9\n409 497 669 384\n735 782 134 846\n220 242 587 911\n421 907 281 324\n627 659 463 876\n591 5 154 468\n620 108 275 255\n685 510 546 304\n841 230 758 108\n298 265 678 954\n721 362 996 861\n546 939 6 665\n531 703 619 463\n793 650 754 495\n157 469 405 881\n510 225 446 546\n379 995 69 777\n532 529 430 401\n995 379 422 404\n501 869 807 251\n244 672 806 251\n930 189 306 507\n991 575 593 713\n203 195 326 414\n652 306 152 289\n620 458 533 544\n847 559 415 283\n334 807 557 810\n750 954 552 330\n788 542 3 817\n717 221 836 992\n167 666 70 275\n480 79 47 893\n84 826 410 298\n454 59 145 200\n702 818 530 791\n519 785 721 776\n624 582 964 139\n6 52 89 665\n782 735 217 465\n105 381 223 737\n765 751 980 803\n868 452 627 381\n504 252 834 558\n111 166 325 412\n205 923 181 805\n749 964 875 275\n560 415 399 257\n648 830 16 110\n868 674 632 462\n82 455 405 333\n903 417 857 468\n846 204 217 735\n135 867 266 29\n846 436 328 355\n987 266 891 680\n789 30 716 764\n607 782 610 22\n329 362 485 676\n233 446 388 945\n155 193 818 529\n52 6 939 372\n691 438 625 626\n624 968 625 950\n583 667 321 600\n781 538 973 412\n17 560 637 545\n789 627 973 391\n344 782 909 355\n873 555 404 232\n507 228 749 653\n879 772 688 239\n226 777 69 464\n134 782 465 494\n619 217 911 253\n714 554 786 976\n533 819 53 681\n39 425 188 774\n160 438 229 435\n739 131 605 964\n149 77 959 726\n176 810 972 10\n373 335 422 715\n464 404 422 226\n364 982 571 655\n139 111 412 715\n740 865 785 712\n8 433 535 357\n534 901 202 251\n995 404 464 69\n296 419 529 551\n918 304 546 446\n351 138 260 788\n924 390 784 698\n572 509 115 158\n411 386 490 352\n287 569 835 542\n195 540 725 754\n597 47 491 679\n738 298 768 873\n186 830 615 477\n587 571 820 711\n391 849 855 476\n724 73 397 374\n540 901 89 932\n166 111 139 66\n225 560 918 446\n268 937 398 189\n336 977 596 570\n488 820 888 734\n410 862 939 154\n727 821 388 358\n952 619 779 310\n315 256 87 839\n702 321 971 122\n26 726 299 446\n859 853 759 181\n253 984 757 382\n481 267 489 824\n203 15 942 102\n132 570 559 856\n980 751 379 137\n452 434 279 953\n360 963 737 130\n491 380 539 501\n597 474 164 153\n559 812 69 138\n592 669 255 234\n730 896 562 734\n332 841 555 305\n103 92 514 534\n143 405 158 748\n416 251 502 651\n723 609 652 856\n975 285 875 343\n442 884 730 76\n497 303 405 669\n632 933 711 715\n834 345 518 108\n129 643 55 50\n652 407 662 958\n587 937 619 625\n747 386 100 85\n604 66 139 715\n486 763 907 825\n590 793 787 825\n36 906 930 107\n447 116 806 711\n217 204 494 465\n40 583 878 49\n254 731 429 598\n603 510 761 992\n12 447 122 488\n64 716 724 872\n584 488 106 991\n514 61 498 879\n741 855 785 481\n810 306 662 426\n238 4 652 758\n962 246 910 980\n574 207 858 732\n446 882 736 66\n429 731 498 61\n918 560 685 304\n827 244 801 282\n506 116 351 171\n776 69 355 519\n646 38 595 530\n176 229 666 958\n753 590 990 642\n38 388 895 990\n50 559 39 62\n267 671 16 535\n643 817 553 996\n541 246 466 646\n317 883 49 106\n522 506 634 634\n164 474 892 55\n963 451 995 704\n623 541 761 810\n928 570 501 559\n340 805 340 553\n416 635 776 177\n300 183 21 800\n398 520 731 451\n552 185 428 785\n577 667 786 163\n396 616 833 203\n559 194 337 615\n355 69 485 398\n666 118 791 632\n66 604 325 166\n887 483 8 671\n63 427 15 584\n80 426 205 307\n919 566 567 501\n860 396 769 91\n128 225 462 716\n775 980 379 456\n973 968 712 87\n26 507 694 377\n344 109 72 40\n278 63 855 560\n511 62 588 844\n249 91 764 788\n24 721 610 431\n411 249 809 480\n472 312 103 405\n931 152 521 724\n731 591 97 237\n204 388 325 759\n13 480 48 601\n145 26 377 955\n75 321 746 366\n326 533 632 526\n864 992 598 961\n274 663 804 802\n18 60 451 736\n556 223 985 487\n844 331 94 646\n82 735 382 616\n686 325 131 799\n828 950 985 152\n561 707 967 454\n89 29 805 640\n716 520 295 975\n992 527 685 629\n349 955 919 204\n256 229 879 969\n811 462 890 989\n739 765 803 307\n29 806 825 168\n514 879 254 598\n372 137 89 52\n854 902 141 590\n729 340 629 376\n534 323 477 805\n665 89 137 546\n602 981 102 696\n743 287 327 561\n600 176 372 822\n545 817 932 626\n61 514 598 429\n454 84 514 619\n347 388 89 544\n460 46 360 598\n996 118 807 127\n794 746 953 369\n751 182 292 300\n365 228 403 330\n765 739 379 751\n377 225 549 646\n911 708 924 448\n934 878 686 686\n592 144 54 472\n980 137 307 803\n282 938 400 467\n239 902 14 293\n801 610 929 686\n841 409 725 14\n879 601 933 230\n659 706 740 995\n6 684 13 513\n784 204 705 151\n570 83 495 866\n631 842 325 29\n491 375 490 697\n431 111 172 56\n610 379 698 671\n576 217 75 354\n870 581 80 824\n652 404 712 642\n486 309 610 758\n622 313 295 423\n607 844 903 393\n64 932 309 426\n720 965 766 581\n38 799 644 550\n402 620 586 280\n132 718 977 696\n951 571 636 354\n954 694 507 607\n158 481 758 585\n738 325 433 371\n453 417 990 493\n600 766 530 260\n763 935 154 88\n705 299 956 211\n739 307 137 379\n385 84 393 657\n700 117 728 462\n588 419 626 156\n394 427 928 829\n127 915 364 579\n416 853 394 132\n933 768 91 51\n721 785 398 485\n312 963 927 254\n259 741 360 367\n819 952 859 906\n179 362 704 919\n538 259 123 71\n22 971 516 20\n21 570 467 635\n294 197 322 988\n849 341 728 227\n642 119 730 114\n5 589 701 224\n69 776 721 485\n650 333 968 426\n260 958 355 108\n617 506 473 489\n727 394 706 821\n309 889 5 73\n775 292 436 624\n547 727 906 34\n73 777 860 96\n362 541 600 335\n429 936 736 907\n13 200 886 306\n980 932 243 153\n796 133 130 721\n741 759 291 741\n384 669 405 940\n807 899 454 193\n996 366 68 946\n464 937 436 673\n127 658 346 456\n445 146 909 123\n154 717 135 200\n969 304 40 354\n127 996 636 372\n941 844 439 223\n762 940 405 303\n18 340 524 971\n54 928 77 681\n722 798 757 224\n599 611 123 419\n642 173 938 251\n259 570 141 173\n657 371 372 233\n517 45 579 500\n700 836 173 239\n846 134 494 204\n64 75 725 7\n256 154 800 997\n703 774 677 420\n120 964 678 739\n992 620 646 813\n762 409 384 940\n220 635 452 964\n31 382 354 0\n379 777 226 422\n229 83 358 198\n662 348 189 771\n355 398 785 519\n879 498 731 254\n508 917 607 24\n521 12 187 51\n325 633 842 295\n921 295 576 308\n363 507 911 389\n196 142 290 305\n607 507 26 145\n940 361 104 245\n949 394 885 206\n319 808 437 881\n955 954 607 145\n325 604 715 412\n36 901 310 171\n297 40 744 715\n106 40 511 370\n330 505 440 565\n546 137 372 939\n",
   "400\n726 684 454 917\n234 437 515 267\n623 149 548 887\n588 534 1 26\n535 867 592 684\n268 685 630 651\n413 536 657 341\n515 24 53 267\n726 917 854 375\n976 223 659 124\n562 792 254 535\n256 888 148 356\n744 836 153 667\n658 66 362 916\n675 240 568 195\n529 239 147 539\n489 302 781 931\n824 465 450 207\n315 53 24 821\n501 429 841 58\n611 525 965 14\n534 240 675 188\n974 6 535 839\n10 737 443 547\n157 749 899 43\n424 747 476 63\n26 51 350 891\n535 464 26 982\n339 427 160 583\n648 325 716 181\n54 25 458 298\n464 535 544 252\n208 870 52 354\n122 659 223 683\n517 396 589 507\n29 721 339 490\n997 479 844 170\n630 757 746 565\n127 402 338 784\n859 148 771 950\n102 329 34 962\n850 920 291 326\n478 291 895 453\n700 624 972 346\n864 938 644 340\n992 490 338 402\n489 388 413 302\n176 302 161 161\n343 928 948 333\n980 719 291 478\n581 450 465 266\n209 775 354 766\n46 926 792 562\n956 197 343 193\n604 915 515 839\n34 688 353 674\n917 454 379 854\n740 395 836 744\n526 371 59 269\n224 204 645 274\n234 267 53 315\n313 535 6 611\n535 588 569 565\n820 323 66 658\n81 639 149 623\n74 703 917 634\n24 244 247 124\n744 667 442 740\n163 644 785 750\n673 887 548 586\n539 850 326 52\n247 262 208 124\n917 524 648 634\n58 841 542 238\n256 714 276 888\n524 917 703 713\n700 196 767 49\n86 534 353 688\n883 22 298 44\n723 217 824 882\n330 573 534 188\n791 420 155 91\n343 333 144 423\n565 379 632 630\n339 593 456 490\n997 897 750 785\n894 518 828 475\n648 794 523 325\n159 951 220 730\n192 954 723 882\n663 424 312 532\n799 374 120 705\n224 274 443 737\n12 793 383 87\n773 913 236 472\n826 974 897 997\n311 12 940 850\n170 162 58 997\n929 763 490 498\n50 804 236 913\n396 214 48 980\n624 176 161 972\n336 674 713 1\n683 288 899 122\n535 528 46 562\n153 836 395 851\n967 685 268 729\n719 338 834 158\n953 680 909 111\n799 705 929 498\n486 409 82 846\n997 785 644 826\n354 52 859 950\n497 67 632 625\n787 151 535 779\n220 157 43 730\n651 630 172 715\n1 329 253 336\n266 465 824 553\n620 816 846 108\n663 371 526 424\n945 413 341 229\n947 252 544 872\n580 338 719 638\n325 523 356 716\n779 535 177 197\n844 46 65 6\n649 577 518 894\n159 757 630 632\n816 620 310 756\n407 193 65 46\n51 26 728 305\n30 980 478 453\n66 323 896 362\n562 729 330 267\n680 767 196 909\n953 111 700 49\n159 411 746 757\n269 97 490 992\n580 638 449 759\n832 507 205 688\n987 510 931 388\n698 836 589 396\n896 750 916 362\n507 517 507 728\n815 604 973 460\n253 984 674 336\n5 611 6 974\n559 5 974 839\n719 158 449 638\n648 524 713 233\n817 813 954 192\n784 97 269 127\n764 818 534 588\n475 828 848 359\n265 914 155 420\n102 962 747 424\n219 1 534 818\n44 298 415 640\n427 339 458 25\n161 161 346 972\n91 101 316 643\n339 583 298 458\n90 399 827 301\n497 867 193 343\n46 528 753 926\n298 383 793 555\n582 238 542 580\n395 740 442 851\n330 188 675 195\n316 101 723 496\n632 904 871 625\n891 729 562 410\n67 497 506 715\n65 193 643 6\n568 240 534 573\n411 379 565 746\n938 311 850 644\n623 887 673 81\n766 4 314 209\n660 214 396 237\n568 573 330 195\n904 715 506 871\n219 818 764 813\n703 239 160 434\n973 604 371 346\n909 179 804 50\n379 437 375 854\n214 660 55 48\n12 864 340 940\n269 992 402 127\n698 208 262 448\n12 109 555 793\n619 846 82 197\n824 207 713 553\n593 687 32 456\n52 326 291 75\n965 525 91 732\n415 768 434 640\n148 859 52 870\n174 643 193 407\n177 230 275 197\n895 169 30 453\n136 543 34 674\n632 379 411 159\n546 703 58 162\n87 383 298 335\n948 384 144 333\n309 723 101 91\n891 350 503 559\n726 375 437 684\n657 749 229 341\n346 371 399 815\n713 207 450 581\n792 926 753 254\n26 813 764 588\n427 920 850 539\n309 91 643 588\n55 660 237 546\n192 882 824 817\n24 124 208 698\n974 826 644 163\n928 405 384 948\n931 781 780 637\n588 535 912 607\n523 794 944 356\n533 700 162 823\n771 208 354 950\n956 781 734 197\n374 799 498 490\n153 851 442 667\n346 161 302 700\n604 839 205 507\n343 423 405 928\n97 784 338 490\n535 254 753 528\n683 223 976 288\n284 329 1 713\n239 703 529 539\n864 12 311 938\n48 55 546 980\n22 883 434 768\n944 181 716 356\n169 719 980 30\n424 526 269 312\n815 460 815 399\n931 637 388 489\n234 315 821 437\n16 354 775 836\n536 413 945 600\n131 669 267 330\n728 836 698 507\n388 637 780 413\n657 536 600 749\n298 583 160 54\n535 313 559 839\n883 44 640 434\n982 26 947 872\n338 580 759 834\n1 219 813 26\n464 252 947 26\n732 91 363 742\n639 81 673 586\n535 565 947 912\n899 288 976 124\n703 434 239 529\n768 415 298 22\n913 773 909 50\n827 399 328 67\n399 90 839 328\n700 111 909 196\n742 14 965 732\n136 534 86 543\n67 328 839 506\n423 144 384 405\n630 962 492 735\n588 643 316 496\n409 486 767 702\n931 684 592 388\n151 230 177 535\n145 232 852 232\n871 506 497 625\n266 553 713 581\n728 26 891 559\n343 197 734 497\n310 386 632 756\n582 580 429 501\n275 787 779 197\n312 269 59 532\n867 781 956 193\n274 645 547 443\n208 771 148 870\n313 611 5 559\n669 131 891 410\n158 834 759 449\n396 517 507 698\n984 284 713 674\n490 49 945 68\n839 90 301 506\n872 544 535 982\n846 619 767 486\n224 737 10 204\n159 730 43 899\n766 354 16 4\n329 102 424 63\n729 268 651 715\n643 174 844 6\n589 836 728 507\n698 448 244 24\n688 515 915 832\n29 32 687 721\n34 476 747 962\n702 767 619 197\n172 967 729 715\n265 288 242 914\n684 437 379 454\n850 940 340 644\n984 253 329 284\n174 407 46 844\n34 543 86 688\n108 386 310 620\n953 49 767 680\n267 669 410 562\n329 63 476 34\n67 506 301 827\n496 723 309 588\n356 148 385 874\n947 918 607 912\n507 832 915 604\n688 205 839 515\n503 350 51 305\n233 713 703 74\n780 781 302 413\n237 396 980 546\n648 233 74 634\n846 816 756 632\n813 817 824 217\n239 539 147 160\n242 91 155 914\n703 546 844 479\n437 821 24 515\n501 58 238 582\n848 828 518 577\n220 951 749 157\n265 420 791 288\n763 120 374 490\n648 181 944 794\n75 427 539 52\n565 569 918 947\n820 750 896 323\n874 385 276 714\n179 909 773 472\n569 588 607 918\n702 197 82 409\n29 490 456 32\n535 684 931 510\n302 176 624 700\n163 750 897 974\n987 388 592 867\n75 291 920 427\n703 479 997 58\n532 59 371 663\n649 359 848 577\n91 242 288 791\n109 335 298 555\n386 108 846 632\n967 172 630 685\n204 10 547 645\n151 787 275 230\n723 954 813 217\n781 867 497 734\n705 120 763 929\n728 559 503 305\n239 434 160 147\n339 721 687 593\n987 867 535 510\n148 888 276 385\n124 659 122 899\n346 815 460 973\n836 314 4 16\n371 604 815 399\n363 91 525 611\n335 109 12 87\n169 895 291 719\n427 25 54 160\n534 136 674 353\n820 658 916 750\n448 262 247 244\n170 844 546 162\n749 951 159 899\n131 330 729 891\n229 749 600 945\n475 359 649 894\n472 236 804 179\n209 314 836 775\n586 548 149 639\n67 715 904 632\n580 542 841 429\n742 363 611 14\n356 874 714 256\n"
  ],
  "outputs": [
   "1\n",
   "144\n",
   "122880\n",
   "673205187207168000\n",
   "222074342031360\n",
   "10358505933768\n",
   "3745910413632\n",
   "15623777496\n",
   "10186200048\n",
   "4140333\n",
   "15383\n",
   "36\n",
   "0\n",
   "0\n",
   "0\n",
   "0\n",
   "0\n",
   "1\n",
   "10\n",
   "66\n"
  ]
 },
 {
  "id": "APPS-3898",
  "question": "A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The center of each island contains an identical pedestal, and all but one of the islands has a fragile, uniquely colored statue currently held on the pedestal. The remaining island holds only an empty pedestal.\n\nThe islanders want to rearrange the statues in a new order. To do this, they repeat the following process: First, they choose an island directly adjacent to the island containing an empty pedestal. Then, they painstakingly carry the statue on this island across the adjoining bridge and place it on the empty pedestal.\n\nDetermine if it is possible for the islanders to arrange the statues in the desired order.\n\n\n-----Input-----\n\nThe first line contains a single integer n (2 ≤ n ≤ 200 000) — the total number of islands.\n\nThe second line contains n space-separated integers a_{i} (0 ≤ a_{i} ≤ n - 1) — the statue currently placed on the i-th island. If a_{i} = 0, then the island has no statue. It is guaranteed that the a_{i} are distinct.\n\nThe third line contains n space-separated integers b_{i} (0 ≤ b_{i} ≤ n - 1) — the desired statues of the ith island. Once again, b_{i} = 0 indicates the island desires no statue. It is guaranteed that the b_{i} are distinct.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes) if the rearrangement can be done in the existing network, and \"NO\" otherwise.\n\n\n-----Examples-----\nInput\n3\n1 0 2\n2 0 1\n\nOutput\nYES\n\nInput\n2\n1 0\n0 1\n\nOutput\nYES\n\nInput\n4\n1 2 3 0\n0 3 2 1\n\nOutput\nNO\n\n\n\n-----Note-----\n\nIn the first sample, the islanders can first move statue 1 from island 1 to island 2, then move statue 2 from island 3 to island 1, and finally move statue 1 from island 2 to island 3.\n\nIn the second sample, the islanders can simply move statue 1 from island 1 to island 2.\n\nIn the third sample, no sequence of movements results in the desired position.",
  "inputs": [
   "3\n1 0 2\n2 0 1\n",
   "2\n1 0\n0 1\n",
   "4\n1 2 3 0\n0 3 2 1\n",
   "9\n3 8 4 6 7 1 5 2 0\n6 4 8 5 3 1 2 0 7\n",
   "4\n2 3 1 0\n2 0 1 3\n",
   "4\n0 1 2 3\n2 0 1 3\n",
   "4\n3 0 1 2\n1 0 2 3\n",
   "3\n0 2 1\n1 2 0\n",
   "2\n0 1\n0 1\n",
   "6\n3 1 5 4 0 2\n0 4 3 5 2 1\n",
   "4\n2 0 3 1\n3 1 0 2\n",
   "5\n3 0 2 1 4\n4 3 0 1 2\n",
   "3\n2 0 1\n1 0 2\n",
   "10\n6 2 3 8 0 4 9 1 5 7\n2 3 8 4 0 9 1 5 7 6\n",
   "10\n2 4 8 3 6 1 9 0 5 7\n3 6 1 9 0 5 7 2 8 4\n",
   "10\n2 0 1 6 4 9 8 5 3 7\n6 4 9 0 5 3 7 2 1 8\n",
   "3\n0 1 2\n0 1 2\n",
   "4\n0 1 2 3\n1 0 2 3\n",
   "3\n0 1 2\n1 0 2\n",
   "5\n1 2 0 3 4\n4 0 1 2 3\n",
   "4\n1 0 2 3\n1 0 2 3\n",
   "3\n0 1 2\n0 2 1\n",
   "4\n0 1 2 3\n2 3 1 0\n",
   "4\n0 2 3 1\n1 2 3 0\n",
   "3\n0 2 1\n2 0 1\n"
  ],
  "outputs": [
   "YES\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n"
  ]
 },
 {
  "id": "APPS-3914",
  "question": "Instructors of Some Informatics School make students go to bed.\n\nThe house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered from 1 to n. Initially, in i-th room there are a_{i} students. All students are currently somewhere in the house, therefore a_1 + a_2 + ... + a_{n} = nb. Also 2 instructors live in this house.\n\nThe process of curfew enforcement is the following. One instructor starts near room 1 and moves toward room n, while the second instructor starts near room n and moves toward room 1. After processing current room, each instructor moves on to the next one. Both instructors enter rooms and move simultaneously, if n is odd, then only the first instructor processes the middle room. When all rooms are processed, the process ends.\n\nWhen an instructor processes a room, she counts the number of students in the room, then turns off the light, and locks the room. Also, if the number of students inside the processed room is not equal to b, the instructor writes down the number of this room into her notebook (and turns off the light, and locks the room). Instructors are in a hurry (to prepare the study plan for the next day), so they don't care about who is in the room, but only about the number of students.\n\nWhile instructors are inside the rooms, students can run between rooms that are not locked and not being processed. A student can run by at most d rooms, that is she can move to a room with number that differs my at most d. Also, after (or instead of) running each student can hide under a bed in a room she is in. In this case the instructor will not count her during the processing. In each room any number of students can hide simultaneously.\n\nFormally, here is what's happening:  A curfew is announced, at this point in room i there are a_{i} students.  Each student can run to another room but not further than d rooms away from her initial room, or stay in place. After that each student can optionally hide under a bed.  Instructors enter room 1 and room n, they count students there and lock the room (after it no one can enter or leave this room).  Each student from rooms with numbers from 2 to n - 1 can run to another room but not further than d rooms away from her current room, or stay in place. Each student can optionally hide under a bed.  Instructors move from room 1 to room 2 and from room n to room n - 1.  This process continues until all rooms are processed. \n\nLet x_1 denote the number of rooms in which the first instructor counted the number of non-hidden students different from b, and x_2 be the same number for the second instructor. Students know that the principal will only listen to one complaint, therefore they want to minimize the maximum of numbers x_{i}. Help them find this value if they use the optimal strategy.\n\n\n-----Input-----\n\nThe first line contains three integers n, d and b (2 ≤ n ≤ 100 000, 1 ≤ d ≤ n - 1, 1 ≤ b ≤ 10 000), number of rooms in the house, running distance of a student, official number of students in a room.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9), i-th of which stands for the number of students in the i-th room before curfew announcement.\n\nIt is guaranteed that a_1 + a_2 + ... + a_{n} = nb.\n\n\n-----Output-----\n\nOutput one integer, the minimal possible value of the maximum of x_{i}.\n\n\n-----Examples-----\nInput\n5 1 1\n1 0 0 0 4\n\nOutput\n1\n\nInput\n6 1 2\n3 8 0 1 0 0\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample the first three rooms are processed by the first instructor, and the last two are processed by the second instructor. One of the optimal strategies is the following: firstly three students run from room 5 to room 4, on the next stage two of them run to room 3, and one of those two hides under a bed. This way, the first instructor writes down room 2, and the second writes down nothing.\n\nIn the second sample one of the optimal strategies is the following: firstly all students in room 1 hide, all students from room 2 run to room 3. On the next stage one student runs from room 3 to room 4, and 5 students hide. This way, the first instructor writes down rooms 1 and 2, the second instructor writes down rooms 5 and 6.",
  "inputs": [
   "5 1 1\n1 0 0 0 4\n",
   "6 1 2\n3 8 0 1 0 0\n",
   "5 1 1\n1 1 0 3 0\n",
   "5 1 1\n4 0 0 1 0\n",
   "2 1 1\n0 2\n",
   "100 66 30\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 27 15 53 29 56 30 24 50 39 39 46 4 14 44 16 55 48 15 54 25 4 44 15 29 55 22 49 52 9 2 22 15 14 33 24 38 11 48 27 34 29 8 37 47 36 54 45 24 31 1434\n",
   "100 2 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 3 1 2 8 5 1 9 1 2 12 7 5 0 7 2 11 3 17\n",
   "100 3 1\n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0 0\n",
   "100 66 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 1 74\n",
   "100 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 8 1 5 4 4 3 1 2 3 8 18 15 4 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n",
   "100 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 6 3 4 2 6 3 4 5 2 5 0 0 0 0 0 0 0 0 0 1 3 5 6 3 1 2 5 1 1 2 0 0 0 0 0 0 0 0 0 3 5 0 0 1 2 2 1 5 7\n",
   "30 1 30\n61 4 40 32 23 35 2 87 20 0 57 21 30 7 16 34 38 18 0 51 61 9 41 22 15 43 47 15 23 48\n",
   "30 2 25\n21 17 30 1 11 13 5 33 21 36 16 54 4 18 28 41 9 42 14 19 39 55 20 4 15 53 13 78 23 17\n",
   "30 3 30\n19 0 64 36 55 24 8 2 6 20 28 58 53 53 56 72 37 7 1 4 96 13 20 51 15 4 13 33 40 12\n",
   "100 2 25\n23 47 16 0 81 70 6 4 31 26 56 58 33 34 23 141 24 18 7 7 2 13 15 8 34 115 7 30 6 7 14 62 3 0 7 73 4 7 5 35 17 26 34 33 12 3 23 27 3 40 2 5 10 10 4 56 50 36 4 14 22 17 7 13 22 85 30 7 10 28 60 35 3 27 0 3 7 52 12 10 74 14 56 54 17 1 50 11 23 2 71 31 11 5 9 10 13 7 16 14\n",
   "100 3 30\n20 10 8 3 97 20 40 4 58 24 105 56 26 21 66 1 126 4 21 46 8 2 9 21 0 13 24 53 58 23 3 107 1 22 189 3 31 4 31 0 3 0 9 43 19 74 92 7 71 22 46 26 31 49 18 3 10 9 9 110 30 2 40 21 33 4 11 14 47 4 1 37 3 19 18 63 10 53 19 35 11 57 8 3 11 27 23 5 45 15 127 27 23 48 3 8 20 33 5 28\n",
   "100 99 15\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30\n",
   "100 1 17\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 56 47 53 49 41 42 52 56 61 42 97 52 55 55 39 54 57 53 67 43 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 22 25 23 27 42 24 28 15 19 19 0 0 0 0 0 0 0 0 0 29 28 33 27 22 25 25 30 31 61\n",
   "100 1 24\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 151 150 159 159 147 121 143 143 138 138 127 127 128 123 159 159 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
  ],
  "outputs": [
   "1\n",
   "2\n",
   "0\n",
   "1\n",
   "0\n",
   "0\n",
   "27\n",
   "16\n",
   "0\n",
   "0\n",
   "0\n",
   "0\n",
   "4\n",
   "7\n",
   "0\n",
   "32\n",
   "25\n",
   "0\n",
   "0\n",
   "0\n",
   "0\n",
   "0\n",
   "0\n",
   "15\n",
   "33\n"
  ]
 },
 {
  "id": "APPS-3931",
  "question": "In the evening Polycarp decided to analyze his today's travel expenses on public transport.\n\nThe bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop to the other and back. There is at most one bus running between a pair of stops.\n\nPolycarp made n trips on buses. About each trip the stop where he started the trip and the the stop where he finished are known. The trips follow in the chronological order in Polycarp's notes.\n\nIt is known that one trip on any bus costs a burles. In case when passenger makes a transshipment the cost of trip decreases to b burles (b < a). A passenger makes a transshipment if the stop on which he boards the bus coincides with the stop where he left the previous bus. Obviously, the first trip can not be made with transshipment.\n\nFor example, if Polycarp made three consecutive trips: \"BerBank\" $\\rightarrow$ \"University\", \"University\" $\\rightarrow$ \"BerMall\", \"University\" $\\rightarrow$ \"BerBank\", then he payed a + b + a = 2a + b burles. From the BerBank he arrived to the University, where he made transshipment to the other bus and departed to the BerMall. Then he walked to the University and returned to the BerBank by bus.\n\nAlso Polycarp can buy no more than k travel cards. Each travel card costs f burles. The travel card for a single bus route makes free of charge any trip by this route (in both directions). Once purchased, a travel card can be used any number of times in any direction.\n\nWhat is the smallest amount of money Polycarp could have spent today if he can buy no more than k travel cards?\n\n\n-----Input-----\n\nThe first line contains five integers n, a, b, k, f (1 ≤ n ≤ 300, 1 ≤ b < a ≤ 100, 0 ≤ k ≤ 300, 1 ≤ f ≤ 1000) where:  n — the number of Polycarp trips,  a — the cost of a regualar single trip,  b — the cost of a trip after a transshipment,  k — the maximum number of travel cards Polycarp can buy,  f — the cost of a single travel card. \n\nThe following n lines describe the trips in the chronological order. Each line contains exactly two different words separated by a single space — the name of the start stop and the name of the finish stop of the trip. All names consist of uppercase and lowercase English letters and have lengths between 1 to 20 letters inclusive. Uppercase and lowercase letters should be considered different.\n\n\n-----Output-----\n\nPrint the smallest amount of money Polycarp could have spent today, if he can purchase no more than k travel cards.\n\n\n-----Examples-----\nInput\n3 5 3 1 8\nBerBank University\nUniversity BerMall\nUniversity BerBank\n\nOutput\n11\n\nInput\n4 2 1 300 1000\na A\nA aa\naa AA\nAA a\n\nOutput\n5\n\n\n\n-----Note-----\n\nIn the first example Polycarp can buy travel card for the route \"BerBank $\\leftrightarrow$ University\" and spend 8 burles. Note that his second trip \"University\" $\\rightarrow$ \"BerMall\" was made after transshipment, so for this trip Polycarp payed 3 burles. So the minimum total sum equals to 8 + 3 = 11 burles.\n\nIn the second example it doesn't make sense to buy travel cards. Note that each of Polycarp trip (except the first) was made with transshipment. So the minimum total sum equals to 2 + 1 + 1 + 1 = 5 burles.",
  "inputs": [
   "3 5 3 1 8\nBerBank University\nUniversity BerMall\nUniversity BerBank\n",
   "4 2 1 300 1000\na A\nA aa\naa AA\nAA a\n",
   "2 2 1 0 1\naca BCBA\nBCBA aca\n",
   "2 2 1 2 1\nBDDB C\nC BDDB\n",
   "2 3 1 1 9\nbacAB aAdb\nbacAB aAdb\n",
   "2 3 1 4 6\nAaCdC CdD\naBACc CdD\n",
   "1 2 1 2 1\nC BA\n",
   "1 3 1 1 4\nbCCCC BC\n",
   "1 4 3 1 1\nC bC\n",
   "1 3 2 1 1\nBBC B\n",
   "3 2 1 5 1\nBCA cBBBd\ncBBBd CdC\nCdC bbdAb\n",
   "5 3 2 1 1\nC CB\nCB C\nC d\nCB d\nCB C\n",
   "3 3 1 0 1\ncbcC A\nA aA\nA cbcC\n",
   "3 3 1 4 3\nc CADC\nCADC ABaD\nABaD c\n",
   "8 2 1 11 1\ndacdD cdDAA\ncdDAA dacdD\ndacdD bcCA\nbcCA B\nDDAA B\nDDAA daC\nAbCAc B\ndacdD daC\n",
   "12 4 1 2 8\nDA b\nDA dC\ndC b\nb DA\nb dC\nDA b\ndC b\nb dC\ndC DA\nDA dC\nDA b\nb dC\n",
   "27 8 1 0 1\nBcd A\nA b\nb BcDc\ndc dbaC\ndbaC dcCB\nB d\nd BbAc\nCBC b\nDBDca d\ncAbb AA\nAA Ba\ncAccb DBDca\ncb DdaB\nAAcBc Ba\nBa dc\ndc DDCd\nbcBDA da\nbDD ADD\nAA b\nb cb\ncb CCBbd\nCCBbd bcDdb\nbcDdb ddc\nddc C\nC Adc\nAdc BbAc\nBbAc DD\n",
   "22 85 1 36 1\ncdAd cBbCa\ncBbCa abBBc\nabBBc dddb\ndddb BBDA\nBBDA abBBc\nabBBc ADCad\naDaC cdAd\ncdAd D\nD acCbD\nAd DB\nDB C\nACb ca\nca ACb\nACb D\nD BBDA\nBBDA d\nd C\nC A\nA B\nB Ad\nAd cDD\ncDD ACb\n",
   "8 8 2 4 5\naBBba C\nCc CcBd\nd C\ndD dDba\ndDba c\nCc d\nd dD\ndD dDba\n",
   "4 10 6 2 7\nbbCc c\nd Bdccd\nBdccd c\nc Bdccd\n",
   "10 3 2 6 2\nbCbA a\naDA Bba\nbCbA aDA\nBba caa\nbCbA Bba\ncaa aDA\naDA bCbA\nbCbA dBba\ndBba bCbA\ndBba a\n",
   "7 5 4 3 2\nDBBCa BdC\nCDBcb BdC\ncA BdC\nBD CDBcb\nBD BdC\nDDd cacD\nBdC cA\n",
   "9 10 5 4 3\nDcAaa caCBc\ncaCBc B\nB b\nb cdddb\ncdddb aDBAb\naDBAb B\nB aDBAb\naDBAb cdddb\ncdddb aDCda\n",
   "10 20 10 0 11\nudgbkX Xe\nXe udgbkX\nudgbkX Xe\nXe udgbkX\nudgbkX Xe\nXe udgbkX\nudgbkX Xe\nXe udgbkX\nudgbkX Xe\nXe udgbkX\n",
   "10 20 10 1 11\nkeJKdQ HS\nHS keJKdQ\nkeJKdQ HS\nHS keJKdQ\nkeJKdQ HS\nHS keJKdQ\nkeJKdQ HS\nHS keJKdQ\nkeJKdQ HS\nHS keJKdQ\n"
  ],
  "outputs": [
   "11\n",
   "5\n",
   "3\n",
   "1\n",
   "6\n",
   "6\n",
   "1\n",
   "3\n",
   "1\n",
   "1\n",
   "3\n",
   "6\n",
   "7\n",
   "5\n",
   "7\n",
   "22\n",
   "111\n",
   "21\n",
   "32\n",
   "24\n",
   "18\n",
   "21\n",
   "27\n",
   "110\n",
   "11\n"
  ]
 },
 {
  "id": "APPS-3941",
  "question": "Moriarty has trapped n people in n distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same time. There are m switches. Each switch control doors of some rooms, but each door is controlled by exactly two switches.\n\nYou are given the initial configuration of the doors. Toggling any switch, that is, turning it ON when it is OFF, or turning it OFF when it is ON, toggles the condition of the doors that this switch controls. Say, we toggled switch 1, which was connected to room 1, 2 and 3 which were respectively locked, unlocked and unlocked. Then, after toggling the switch, they become unlocked, locked and locked.\n\nYou need to tell Sherlock, if there exists a way to unlock all doors at the same time.\n\n\n-----Input-----\n\nFirst line of input contains two integers n and m (2 ≤ n ≤ 10^5, 2 ≤ m ≤ 10^5) — the number of rooms and the number of switches.\n\nNext line contains n space-separated integers r_1, r_2, ..., r_{n} (0 ≤ r_{i} ≤ 1) which tell the status of room doors. The i-th room is locked if r_{i} = 0, otherwise it is unlocked.\n\nThe i-th of next m lines contains an integer x_{i} (0 ≤ x_{i} ≤ n) followed by x_{i} distinct integers separated by space, denoting the number of rooms controlled by the i-th switch followed by the room numbers that this switch controls. It is guaranteed that the room numbers are in the range from 1 to n. It is guaranteed that each door is controlled by exactly two switches.\n\n\n-----Output-----\n\nOutput \"YES\" without quotes, if it is possible to open all doors at the same time, otherwise output \"NO\" without quotes.\n\n\n-----Examples-----\nInput\n3 3\n1 0 1\n2 1 3\n2 1 2\n2 2 3\n\nOutput\nNO\nInput\n3 3\n1 0 1\n3 1 2 3\n1 2\n2 1 3\n\nOutput\nYES\nInput\n3 3\n1 0 1\n3 1 2 3\n2 1 2\n1 3\n\nOutput\nNO\n\n\n-----Note-----\n\nIn the second example input, the initial statuses of the doors are [1, 0, 1] (0 means locked, 1 — unlocked).\n\nAfter toggling switch 3, we get [0, 0, 0] that means all doors are locked.\n\nThen, after toggling switch 1, we get [1, 1, 1] that means all doors are unlocked.\n\nIt can be seen that for the first and for the third example inputs it is not possible to make all doors unlocked.",
  "inputs": [
   "3 3\n1 0 1\n2 1 3\n2 1 2\n2 2 3\n",
   "3 3\n1 0 1\n3 1 2 3\n1 2\n2 1 3\n",
   "3 3\n1 0 1\n3 1 2 3\n2 1 2\n1 3\n",
   "11 10\n0 0 1 0 0 0 0 1 1 0 1\n3 2 3 11\n1 3\n2 6 7\n1 5\n1 11\n1 10\n5 4 6 8 9 10\n2 1 5\n1 7\n5 1 2 4 8 9\n",
   "10 9\n1 0 1 1 0 1 0 0 1 0\n4 2 3 9 10\n4 3 4 5 8\n2 1 6\n2 7 8\n1 7\n1 5\n1 10\n2 2 4\n3 1 6 9\n",
   "13 11\n0 1 1 0 1 0 0 0 1 0 0 1 1\n6 2 8 9 11 12 13\n3 1 3 11\n1 12\n1 7\n3 6 10 13\n3 1 3 8\n2 7 9\n1 4\n1 2\n2 5 10\n3 4 5 6\n",
   "7 6\n0 0 1 0 1 0 0\n1 7\n4 1 2 5 7\n2 4 6\n2 4 5\n3 1 3 6\n2 2 3\n",
   "2 2\n1 0\n2 1 2\n2 1 2\n",
   "2 2\n0 0\n2 1 2\n2 1 2\n",
   "4 4\n0 1 0 1\n2 1 2\n2 2 3\n2 3 4\n2 1 4\n",
   "2 2\n1 1\n2 1 2\n2 1 2\n",
   "4 4\n0 0 1 1\n2 1 3\n2 2 3\n2 1 4\n2 2 4\n",
   "4 4\n0 1 0 1\n2 1 2\n2 2 3\n2 3 4\n2 4 1\n",
   "2 3\n1 0\n1 1\n2 1 2\n1 2\n",
   "4 5\n0 0 0 1\n2 1 2\n1 1\n2 2 3\n2 3 4\n1 4\n",
   "3 6\n0 0 0\n0\n0\n0\n2 1 2\n2 2 3\n2 1 3\n",
   "3 3\n1 0 0\n2 1 2\n2 1 3\n2 2 3\n",
   "4 4\n0 0 0 0\n2 1 2\n2 1 2\n2 3 4\n2 3 4\n",
   "3 3\n0 1 0\n2 1 3\n2 1 2\n2 2 3\n",
   "3 3\n0 1 0\n2 1 3\n2 2 3\n2 1 2\n",
   "4 4\n1 1 1 0\n2 1 2\n2 1 2\n2 3 4\n2 3 4\n",
   "3 4\n1 1 0\n2 1 2\n2 1 2\n1 3\n1 3\n",
   "2 4\n0 0\n1 1\n1 1\n1 2\n1 2\n",
   "3 3\n0 0 0\n2 1 2\n2 2 3\n2 1 3\n"
  ],
  "outputs": [
   "NO",
   "YES",
   "NO",
   "NO",
   "NO",
   "NO",
   "NO",
   "NO",
   "YES",
   "YES",
   "YES",
   "YES",
   "YES",
   "YES",
   "YES",
   "NO",
   "YES",
   "YES",
   "YES",
   "YES",
   "NO",
   "YES",
   "YES",
   "NO"
  ]
 },
 {
  "id": "APPS-3847",
  "question": "You are given two arrays $a$ and $b$ of positive integers, with length $n$ and $m$ respectively. \n\nLet $c$ be an $n \\times m$ matrix, where $c_{i,j} = a_i \\cdot b_j$. \n\nYou need to find a subrectangle of the matrix $c$ such that the sum of its elements is at most $x$, and its area (the total number of elements) is the largest possible.\n\nFormally, you need to find the largest number $s$ such that it is possible to choose integers $x_1, x_2, y_1, y_2$ subject to $1 \\leq x_1 \\leq x_2 \\leq n$, $1 \\leq y_1 \\leq y_2 \\leq m$, $(x_2 - x_1 + 1) \\times (y_2 - y_1 + 1) = s$, and $$\\sum_{i=x_1}^{x_2}{\\sum_{j=y_1}^{y_2}{c_{i,j}}} \\leq x.$$\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $m$ ($1 \\leq n, m \\leq 2000$).\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq 2000$).\n\nThe third line contains $m$ integers $b_1, b_2, \\ldots, b_m$ ($1 \\leq b_i \\leq 2000$).\n\nThe fourth line contains a single integer $x$ ($1 \\leq x \\leq 2 \\cdot 10^{9}$).\n\n\n-----Output-----\n\nIf it is possible to choose four integers $x_1, x_2, y_1, y_2$ such that $1 \\leq x_1 \\leq x_2 \\leq n$, $1 \\leq y_1 \\leq y_2 \\leq m$, and $\\sum_{i=x_1}^{x_2}{\\sum_{j=y_1}^{y_2}{c_{i,j}}} \\leq x$, output the largest value of $(x_2 - x_1 + 1) \\times (y_2 - y_1 + 1)$ among all such quadruplets, otherwise output $0$.\n\n\n-----Examples-----\nInput\n3 3\n1 2 3\n1 2 3\n9\n\nOutput\n4\n\nInput\n5 1\n5 4 2 4 5\n2\n5\n\nOutput\n1\n\n\n\n-----Note-----\n\nMatrix from the first sample and the chosen subrectangle (of blue color):\n\n [Image] \n\nMatrix from the second sample and the chosen subrectangle (of blue color):\n\n $\\left. \\begin{array}{l l l l l}{10} & {8} & {4} & {8} & {10} \\end{array} \\right.$",
  "inputs": [
   "3 3\n1 2 3\n1 2 3\n9\n",
   "5 1\n5 4 2 4 5\n2\n5\n",
   "1 1\n1\n1\n1\n",
   "5 5\n816 1061 1639 1627 1007\n45 104 1091 592 1881\n84465\n",
   "5 5\n816 1061 1639 1627 1007\n45 104 1091 592 1881\n36719\n",
   "5 5\n816 1061 1639 1627 1007\n45 104 1091 592 1881\n165947710\n",
   "1 5\n549\n1422 1870 569 844 1178\n340452749\n",
   "1 10\n491\n980 1907 1241 336 811 1048 957 440 143 1835\n938294862\n",
   "1 50\n758\n1915 1868 1403 691 77 403 1322 701 1192 1463 911 1029 1471 1610 736 1501 1243 1327 1624 412 455 177 371 750 1156 989 1861 498 567 803 1140 346 1654 1961 330 718 943 1880 1476 1193 1666 1757 405 202 417 585 1812 293 791 1858\n1796075481\n",
   "1 100\n1612\n1989 1820 1837 815 943 208 131 1252 1372 145 1182 1200 499 1312 1390 829 1343 1378 280 492 609 1439 1128 1597 123 372 953 472 1078 1522 526 1639 1357 1452 1357 89 480 1597 783 177 1106 688 1426 1334 1292 406 1959 1649 1768 1956 1844 273 454 354 1170 1514 10 557 1472 1697 1004 485 1870 1394 102 400 883 1979 938 501 1368 1038 922 1090 1339 1379 254 1335 1853 1923 1249 1449 1588 334 1460 256 1386 918 1818 409 236 1538 346 1860 587 268 81 1015 1838 1955\n1774052077\n",
   "5 1\n416 387 336 116 1081\n553\n193993787\n",
   "10 1\n451 732 428 1649 428 1821 1098 756 1599 377\n1567\n301515216\n",
   "50 1\n420 738 531 1575 1728 842 346 786 328 1944 942 1577 1247 1409 194 1398 1417 337 1886 83 559 1125 1741 481 1935 624 893 1028 1626 1143 257 1556 261 1429 642 1997 1720 1400 250 944 466 34 679 160 1138 1688 975 1862 336 1959\n1878\n27853310\n",
   "100 1\n1525 1915 925 1023 803 904 802 1943 954 23 258 505 972 571 1291 1024 161 461 1020 880 67 1975 1612 1599 1024 682 1810 500 1068 1992 1834 79 476 842 1366 17 1307 1595 587 367 1961 1018 960 1699 1799 1453 1890 1003 780 601 131 808 83 26 1894 1345 1835 674 629 525 709 754 988 1612 810 1618 1979 1871 755 1279 407 1052 1951 1047 729 363 1392 1039 701 1915 414 1102 693 1870 1426 447 1428 1272 1500 51 1396 1332 111 556 1440 1199 511 212 42 1547\n1882\n984199988\n",
   "10 10\n461 1459 597 616 902 1894 1457 1248 691 493\n1230 150 75 1793 1567 206 1661 560 956 1856\n1614959273\n",
   "50 50\n175 1571 1423 1837 1228 1923 1369 1875 1105 1762 203 1011 1596 1500 1213 950 557 451 8 390 1704 606 1084 227 1911 1189 795 481 1510 1862 348 1352 69 387 697 595 330 274 721 1842 1836 1164 1031 1880 281 1150 256 1853 1233 1499\n1977 1404 1816 1031 1712 390 328 1646 342 462 685 523 435 1548 1383 1649 690 538 1291 1558 720 1145 307 1219 321 109 825 37 1836 989 1360 15 1610 852 923 1734 250 1539 612 1059 96 28 1415 293 1490 1016 1700 908 730 1395\n976257664\n",
   "1 5\n549\n1422 1870 569 844 1178\n3229767\n",
   "1 10\n491\n980 1907 1241 336 811 1048 957 440 143 1835\n1668909\n",
   "1 50\n758\n1915 1868 1403 691 77 403 1322 701 1192 1463 911 1029 1471 1610 736 1501 1243 1327 1624 412 455 177 371 750 1156 989 1861 498 567 803 1140 346 1654 1961 330 718 943 1880 1476 1193 1666 1757 405 202 417 585 1812 293 791 1858\n28031598\n",
   "1 100\n1612\n1989 1820 1837 815 943 208 131 1252 1372 145 1182 1200 499 1312 1390 829 1343 1378 280 492 609 1439 1128 1597 123 372 953 472 1078 1522 526 1639 1357 1452 1357 89 480 1597 783 177 1106 688 1426 1334 1292 406 1959 1649 1768 1956 1844 273 454 354 1170 1514 10 557 1472 1697 1004 485 1870 1394 102 400 883 1979 938 501 1368 1038 922 1090 1339 1379 254 1335 1853 1923 1249 1449 1588 334 1460 256 1386 918 1818 409 236 1538 346 1860 587 268 81 1015 1838 1955\n6983184\n",
   "5 1\n416 387 336 116 1081\n553\n463967\n",
   "10 1\n451 732 428 1649 428 1821 1098 756 1599 377\n1567\n14634213\n",
   "50 1\n420 738 531 1575 1728 842 346 786 328 1944 942 1577 1247 1409 194 1398 1417 337 1886 83 559 1125 1741 481 1935 624 893 1028 1626 1143 257 1556 261 1429 642 1997 1720 1400 250 944 466 34 679 160 1138 1688 975 1862 336 1959\n1878\n16023096\n",
   "100 1\n1525 1915 925 1023 803 904 802 1943 954 23 258 505 972 571 1291 1024 161 461 1020 880 67 1975 1612 1599 1024 682 1810 500 1068 1992 1834 79 476 842 1366 17 1307 1595 587 367 1961 1018 960 1699 1799 1453 1890 1003 780 601 131 808 83 26 1894 1345 1835 674 629 525 709 754 988 1612 810 1618 1979 1871 755 1279 407 1052 1951 1047 729 363 1392 1039 701 1915 414 1102 693 1870 1426 447 1428 1272 1500 51 1396 1332 111 556 1440 1199 511 212 42 1547\n1882\n70074388\n",
   "10 10\n461 1459 597 616 902 1894 1457 1248 691 493\n1230 150 75 1793 1567 206 1661 560 956 1856\n15296685\n"
  ],
  "outputs": [
   "4\n",
   "1\n",
   "1\n",
   "2\n",
   "0\n",
   "25\n",
   "5\n",
   "10\n",
   "50\n",
   "100\n",
   "5\n",
   "10\n",
   "16\n",
   "100\n",
   "100\n",
   "1305\n",
   "5\n",
   "5\n",
   "37\n",
   "7\n",
   "3\n",
   "10\n",
   "11\n",
   "39\n",
   "30\n"
  ]
 },
 {
  "id": "APPS-3694",
  "question": "Tokitsukaze and CSL are playing a little game of stones.\n\nIn the beginning, there are $n$ piles of stones, the $i$-th pile of which has $a_i$ stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty pile and removes exactly one stone from the pile. A player loses if all of the piles are empty before his turn, or if after removing the stone, two piles (possibly empty) contain the same number of stones. Supposing that both players play optimally, who will win the game?\n\nConsider an example: $n=3$ and sizes of piles are $a_1=2$, $a_2=3$, $a_3=0$. It is impossible to choose the empty pile, so Tokitsukaze has two choices: the first and the second piles. If she chooses the first pile then the state will be $[1, 3, 0]$ and it is a good move. But if she chooses the second pile then the state will be $[2, 2, 0]$ and she immediately loses. So the only good move for her is to choose the first pile. \n\nSupposing that both players always take their best moves and never make mistakes, who will win the game?\n\nNote that even if there are two piles with the same number of stones at the beginning, Tokitsukaze may still be able to make a valid first move. It is only necessary that there are no two piles with the same number of stones after she moves.\n\n\n-----Input-----\n\nThe first line contains a single integer $n$ ($1 \\le n \\le 10^5$) — the number of piles.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_1, a_2, \\ldots, a_n \\le 10^9$), which mean the $i$-th pile has $a_i$ stones.\n\n\n-----Output-----\n\nPrint \"sjfnb\" (without quotes) if Tokitsukaze will win, or \"cslnb\" (without quotes) if CSL will win. Note the output characters are case-sensitive.\n\n\n-----Examples-----\nInput\n1\n0\n\nOutput\ncslnb\n\nInput\n2\n1 0\n\nOutput\ncslnb\n\nInput\n2\n2 2\n\nOutput\nsjfnb\n\nInput\n3\n2 3 1\n\nOutput\nsjfnb\n\n\n\n-----Note-----\n\nIn the first example, Tokitsukaze cannot take any stone, so CSL will win.\n\nIn the second example, Tokitsukaze can only take a stone from the first pile, and then, even though they have no stone, these two piles will have the same number of stones, which implies CSL will win.\n\nIn the third example, Tokitsukaze will win. Here is one of the optimal ways:\n\n  Firstly, Tokitsukaze can choose the first pile and take a stone from that pile.  Then, CSL can only choose the first pile, because if he chooses the second pile, he will lose immediately.  Finally, Tokitsukaze can choose the second pile, and then CSL will have no choice but to lose. \n\nIn the fourth example, they only have one good choice at any time, so Tokitsukaze can make the game lasting as long as possible and finally win.",
  "inputs": [
   "1\n0\n",
   "2\n1 0\n",
   "2\n2 2\n",
   "3\n2 3 1\n",
   "3\n3 3 3\n",
   "3\n4 4 4\n",
   "4\n2 2 4 4\n",
   "5\n2 2 4 4 7\n",
   "7\n7 7 7 1 0 2 3\n",
   "7\n7 7 7 1 0 2 4\n",
   "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n",
   "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125477\n",
   "14\n6 66 89 84 89 66 123456 98745 3685 21457 15987 36528 14578 98658\n",
   "14\n6 66 89 84 89 66 123456 98745 3685 21457 15987 36528 14578 98633\n",
   "9\n8004 5687 1235 8004 5687 1235 999 789555 1222230\n",
   "9\n8004 5687 1235 8004 5687 1235 999 789555 1222235\n",
   "3\n0 0 5\n",
   "3\n0 0 6\n",
   "3\n3 4 4\n",
   "3\n4 5 5\n",
   "5\n0 5 6 7 8\n",
   "5\n0 5 6 7 9\n",
   "5\n0 0 1 5 8\n",
   "5\n0 0 1 5 9\n",
   "5\n0 0 0 999 555\n"
  ],
  "outputs": [
   "cslnb\n",
   "cslnb\n",
   "sjfnb\n",
   "sjfnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "sjfnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n",
   "sjfnb\n",
   "cslnb\n",
   "cslnb\n",
   "cslnb\n"
  ]
 },
 {
  "id": "APPS-3986",
  "question": "Little penguin Polo adores strings. But most of all he adores strings of length n.\n\nOne day he wanted to find a string that meets the following conditions:  The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct.  No two neighbouring letters of a string coincide; that is, if we represent a string as s = s_1s_2... s_{n}, then the following inequality holds, s_{i} ≠ s_{i} + 1(1 ≤ i < n).  Among all strings that meet points 1 and 2, the required string is lexicographically smallest. \n\nHelp him find such string or state that such string doesn't exist.\n\nString x = x_1x_2... x_{p} is lexicographically less than string y = y_1y_2... y_{q}, if either p < q and x_1 = y_1, x_2 = y_2, ... , x_{p} = y_{p}, or there is such number r (r < p, r < q), that x_1 = y_1, x_2 = y_2, ... , x_{r} = y_{r} and x_{r} + 1 < y_{r} + 1. The characters of the strings are compared by their ASCII codes.\n\n\n-----Input-----\n\nA single line contains two positive integers n and k (1 ≤ n ≤ 10^6, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.\n\n\n-----Output-----\n\nIn a single line print the required string. If there isn't such string, print \"-1\" (without the quotes).\n\n\n-----Examples-----\nInput\n7 4\n\nOutput\nababacd\n\nInput\n4 7\n\nOutput\n-1",
  "inputs": [
   "7 4\n",
   "4 7\n",
   "10 5\n",
   "47 2\n",
   "10 7\n",
   "20 7\n",
   "26 26\n",
   "47 1\n",
   "128 26\n",
   "4585 1\n",
   "1000000 1\n",
   "6795 1\n",
   "12 17\n",
   "1 1\n",
   "2 2\n",
   "1 2\n",
   "1 26\n",
   "26 2\n",
   "123 21\n",
   "3 3\n"
  ],
  "outputs": [
   "ababacd\n",
   "-1\n",
   "abababacde\n",
   "abababababababababababababababababababababababa\n",
   "ababacdefg\n",
   "abababababababacdefg\n",
   "abcdefghijklmnopqrstuvwxyz\n",
   "-1\n",
   "ababababababababababababababababababababababababababababababababababababababababababababababababababababcdefghijklmnopqrstuvwxyz\n",
   "-1\n",
   "-1\n",
   "-1\n",
   "-1\n",
   "a\n",
   "ab\n",
   "-1\n",
   "-1\n",
   "ababababababababababababab\n",
   "ababababababababababababababababababababababababababababababababababababababababababababababababababababcdefghijklmnopqrstu\n",
   "abc\n"
  ]
 },
 {
  "id": "APPS-3840",
  "question": "Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has a_{i} coins. \n\nPolycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and take a coin from each chest with numbers x, 2·x, 2·x + 1. It may turn out that some chest has no coins, in this case the player doesn't take a coin from this chest. The game finishes when all chests get emptied.\n\nPolycarpus isn't a greedy scrooge. Polycarpys is a lazy slob. So he wonders in what minimum number of moves the game can finish. Help Polycarpus, determine the minimum number of moves in which the game can finish. Note that Polycarpus counts not only his moves, he also counts Vasily's moves.\n\n\n-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000), where a_{i} is the number of coins in the chest number i at the beginning of the game.\n\n\n-----Output-----\n\nPrint a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1.\n\n\n-----Examples-----\nInput\n1\n1\n\nOutput\n-1\n\nInput\n3\n1 2 3\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.\n\nIn the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest.",
  "inputs": [
   "1\n1\n",
   "3\n1 2 3\n",
   "100\n269 608 534 956 993 409 297 735 258 451 468 422 125 407 580 769 857 383 419 67 377 230 842 113 169 427 287 75 372 133 456 450 644 303 638 40 217 445 427 730 168 341 371 633 237 951 142 596 528 509 236 782 44 467 607 326 267 15 564 858 499 337 74 346 443 436 48 795 206 403 379 313 382 620 341 978 209 696 879 810 872 336 983 281 602 521 762 782 733 184 307 567 245 983 201 966 546 70 5 973\n",
   "99\n557 852 325 459 557 350 719 719 400 228 985 674 942 322 212 553 191 58 720 262 798 884 20 275 576 971 684 340 581 175 641 552 190 277 293 928 261 504 83 950 423 211 571 159 44 428 131 273 181 555 430 437 901 376 361 989 225 399 712 935 279 975 525 631 442 558 457 904 491 598 321 396 537 555 73 415 842 162 284 847 847 139 305 150 300 664 831 894 260 747 466 563 97 907 42 340 553 471 411\n",
   "98\n204 880 89 270 128 298 522 176 611 49 492 475 977 701 197 837 600 361 355 70 640 472 312 510 914 665 869 105 411 812 74 324 727 412 161 703 392 364 752 74 446 156 333 82 557 764 145 803 36 293 776 276 810 909 877 488 521 865 200 817 445 577 49 165 755 961 867 819 260 836 276 756 649 169 457 28 598 328 692 487 673 563 24 310 913 639 824 346 481 538 509 861 764 108 479 14 552 752\n",
   "97\n691 452 909 730 594 55 622 633 13 359 246 925 172 25 535 930 170 528 933 878 130 548 253 745 116 494 862 574 888 609 18 448 208 354 133 181 330 89 364 198 412 157 152 300 910 99 808 228 435 872 985 364 911 634 289 235 761 978 631 212 314 828 277 347 965 524 222 381 84 970 743 116 57 975 33 289 194 493 853 584 338 987 686 926 718 806 170 902 349 137 849 671 783 853 564 495 711\n",
   "96\n529 832 728 246 165 3 425 338 520 373 945 726 208 404 329 918 579 183 319 38 268 136 353 980 614 483 47 987 717 54 451 275 938 841 649 147 917 949 169 322 626 103 266 415 423 627 822 757 641 610 331 203 172 814 806 734 706 147 119 798 480 622 153 176 278 735 632 944 853 400 699 476 976 589 417 446 141 307 557 576 355 763 404 87 332 429 516 649 570 279 893 969 154 246 353 920\n",
   "95\n368 756 196 705 632 759 228 794 922 387 803 176 755 727 963 658 797 190 249 845 110 916 941 215 655 17 95 751 2 396 395 47 419 784 325 626 856 969 838 501 945 48 84 689 423 963 485 831 848 189 540 42 273 243 322 288 106 260 550 681 542 224 677 902 295 490 338 858 325 638 6 484 88 746 697 355 385 472 262 864 77 378 419 55 945 109 862 101 982 70 936 323 822 447 437\n",
   "94\n311 135 312 221 906 708 32 251 677 753 502 329 790 106 949 942 558 845 532 949 952 800 585 450 857 198 88 516 832 193 532 171 253 918 194 752 339 534 450 625 967 345 199 612 936 650 499 256 191 576 590 73 374 968 382 139 50 725 38 76 763 827 905 83 801 53 748 421 94 420 665 844 496 360 81 512 685 638 671 960 902 802 785 863 558 276 15 305 202 669 276 621 841 192\n",
   "1\n546\n",
   "2\n707 629\n",
   "3\n868 762 256\n",
   "4\n221 30 141 672\n",
   "5\n86 458 321 157 829\n",
   "6\n599 78 853 537 67 706\n",
   "7\n760 154 34 77 792 950 159\n",
   "8\n113 583 918 562 325 1 60 769\n",
   "9\n275 555 451 102 755 245 256 312 230\n",
   "10\n636 688 843 886 13 751 884 120 880 439\n",
   "11\n989 117 23 371 442 803 81 768 182 425 888\n",
   "55\n1 1 2 2 2 2 1 1 1 1 2 1 2 1 2 2 1 1 2 2 1 2 1 2 1 1 1 2 1 2 2 2 1 2 2 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 2 2 2 2 2\n",
   "43\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
   "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
   "77\n1000 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\n",
   "100\n999 1000 999 999 1000 1000 999 1000 999 999 999 999 1000 1000 1000 1000 1000 999 999 999 1000 999 1000 999 999 1000 1000 1000 1000 1000 1000 999 999 1000 1000 999 1000 1000 999 999 999 1000 999 1000 999 999 999 999 1000 1000 999 999 1000 999 1000 999 999 1000 999 1000 999 1000 1000 1000 999 1000 999 999 1000 1000 1000 1000 999 999 999 999 1000 1000 1000 1000 1000 1000 999 1000 1000 999 999 999 1000 999 1000 999 1000 1000 1000 999 999 1000 999 1000\n"
  ],
  "outputs": [
   "-1\n",
   "3\n",
   "-1\n",
   "23450\n",
   "-1\n",
   "25165\n",
   "-1\n",
   "23078\n",
   "-1\n",
   "-1\n",
   "-1\n",
   "868\n",
   "-1\n",
   "1150\n",
   "-1\n",
   "2502\n",
   "-1\n",
   "1598\n",
   "-1\n",
   "3448\n",
   "32\n",
   "15\n",
   "-1\n",
   "27000\n",
   "-1\n"
  ]
 },
 {
  "id": "APPS-3855",
  "question": "You have $n$ coins, each of the same value of $1$.\n\nDistribute them into packets such that any amount $x$ ($1 \\leq x \\leq n$) can be formed using some (possibly one or all) number of these packets.\n\nEach packet may only be used entirely or not used at all. No packet may be used more than once in the formation of the single $x$, however it may be reused for the formation of other $x$'s.\n\nFind the minimum number of packets in such a distribution.\n\n\n-----Input-----\n\nThe only line contains a single integer $n$ ($1 \\leq n \\leq 10^9$) — the number of coins you have.\n\n\n-----Output-----\n\nOutput a single integer — the minimum possible number of packets, satisfying the condition above.\n\n\n-----Examples-----\nInput\n6\n\nOutput\n3\nInput\n2\n\nOutput\n2\n\n\n-----Note-----\n\nIn the first example, three packets with $1$, $2$ and $3$ coins can be made to get any amount $x$ ($1\\leq x\\leq 6$).  To get $1$ use the packet with $1$ coin.  To get $2$ use the packet with $2$ coins.  To get $3$ use the packet with $3$ coins.  To get $4$ use packets with $1$ and $3$ coins.  To get $5$ use packets with $2$ and $3$ coins  To get $6$ use all packets. \n\nIn the second example, two packets with $1$ and $1$ coins can be made to get any amount $x$ ($1\\leq x\\leq 2$).",
  "inputs": [
   "6\n",
   "2\n",
   "1\n",
   "1000000000\n",
   "96145460\n",
   "47814355\n",
   "33554430\n",
   "33554431\n",
   "33554432\n",
   "33554434\n",
   "946942894\n",
   "40052789\n",
   "781222222\n",
   "723061816\n",
   "108461089\n",
   "517188853\n",
   "237913214\n",
   "952679912\n",
   "458841431\n",
   "654645765\n",
   "543654364\n",
   "222222222\n",
   "32453535\n",
   "435543666\n",
   "443566\n"
  ],
  "outputs": [
   "3",
   "2",
   "1",
   "30",
   "27",
   "26",
   "25",
   "25",
   "26",
   "26",
   "30",
   "26",
   "30",
   "30",
   "27",
   "29",
   "28",
   "30",
   "29",
   "30",
   "30",
   "28",
   "25",
   "29",
   "19"
  ]
 },
 {
  "id": "APPS-3969",
  "question": "Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.\n\nOver the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is very narrow and can be viewed as an infinite line, with each plant occupying a single point on that line.\n\nEmuskald has discovered that each species thrives at a different temperature, so he wants to arrange m - 1 borders that would divide the greenhouse into m sections numbered from 1 to m from left to right with each section housing a single species. He is free to place the borders, but in the end all of the i-th species plants must reside in i-th section from the left.\n\nOf course, it is not always possible to place the borders in such way, so Emuskald needs to replant some of his plants. He can remove each plant from its position and place it anywhere in the greenhouse (at any real coordinate) with no plant already in it. Since replanting is a lot of stress for the plants, help Emuskald find the minimum number of plants he has to replant to be able to place the borders.\n\n\n-----Input-----\n\nThe first line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 5000, n ≥ m), the number of plants and the number of different species. Each of the following n lines contain two space-separated numbers: one integer number s_{i} (1 ≤ s_{i} ≤ m), and one real number x_{i} (0 ≤ x_{i} ≤ 10^9), the species and position of the i-th plant. Each x_{i} will contain no more than 6 digits after the decimal point.\n\nIt is guaranteed that all x_{i} are different; there is at least one plant of each species; the plants are given in order \"from left to the right\", that is in the ascending order of their x_{i} coordinates (x_{i} < x_{i} + 1, 1 ≤ i < n).\n\n\n-----Output-----\n\nOutput a single integer — the minimum number of plants to be replanted.\n\n\n-----Examples-----\nInput\n3 2\n2 1\n1 2.0\n1 3.100\n\nOutput\n1\n\nInput\n3 3\n1 5.0\n2 5.5\n3 6.0\n\nOutput\n0\n\nInput\n6 3\n1 14.284235\n2 17.921382\n1 20.328172\n3 20.842331\n1 25.790145\n1 27.204125\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first test case, Emuskald can replant the first plant to the right of the last plant, so the answer is 1.\n\nIn the second test case, the species are already in the correct order, so no replanting is needed.",
  "inputs": [
   "3 2\n2 1\n1 2.0\n1 3.100\n",
   "3 3\n1 5.0\n2 5.5\n3 6.0\n",
   "6 3\n1 14.284235\n2 17.921382\n1 20.328172\n3 20.842331\n1 25.790145\n1 27.204125\n",
   "1 1\n1 0\n",
   "8 2\n1 0.000000\n1 1.000000\n1 2.000000\n2 2.000001\n1 999999997.000000\n2 999999998.000000\n2 999999999.999999\n2 1000000000.000000\n",
   "15 5\n4 6.039627\n2 7.255149\n2 14.469785\n2 15.108572\n4 22.570081\n5 26.642253\n5 32.129202\n5 44.288220\n5 53.231909\n5 60.548042\n4 62.386581\n2 77.828816\n1 87.998512\n3 96.163559\n2 99.412872\n",
   "10 7\n4 70882.412953\n1 100461.912159\n3 100813.254090\n7 121632.112636\n2 424085.529781\n6 510966.713362\n6 543441.105338\n7 680094.776949\n1 721404.212606\n5 838754.272757\n",
   "5 5\n5 0\n4 1\n3 2\n2 3\n1 4\n",
   "12 5\n2 0\n2 1\n3 2\n3 3\n3 4\n1 5\n5 6\n3 7\n3 8\n3 9\n4 999999999\n4 1000000000\n",
   "3 3\n2 0\n1 1\n3 2\n",
   "3 3\n3 0\n1 1\n2 2\n",
   "4 2\n1 10\n2 20\n1 30\n2 40\n",
   "20 10\n1 0.000000\n2 0.000001\n3 0.000002\n4 0.000003\n5 0.000004\n6 0.000005\n7 0.000006\n8 0.000007\n9 0.000008\n10 0.000009\n1 999999999.999990\n2 999999999.999991\n3 999999999.999992\n4 999999999.999993\n5 999999999.999994\n6 999999999.999995\n7 999999999.999996\n8 999999999.999997\n9 999999999.999998\n10 999999999.999999\n",
   "12 4\n3 0\n3 1\n3 2\n3 3\n3 4\n1 5\n1 6\n2 7\n4 8\n4 9\n2 10\n3 11\n",
   "16 2\n1 0\n1 1\n2 2\n2 3\n2 4\n2 5\n1 6\n1 7\n2 8\n2 9\n1 10\n1 11\n2 12\n2 13\n2 14\n2 15\n",
   "10 10\n1 100\n2 101\n3 102\n5 103\n9 1000\n8 10000\n6 100000\n7 1000000\n4 10000000\n10 100000000\n",
   "10 6\n5 50837.108162\n3 111993.624183\n1 207268.919250\n6 567963.419694\n1 621364.247371\n2 630118.065585\n1 642135.221942\n6 642673.884754\n5 647004.198361\n4 735196.102629\n",
   "20 2\n1 39277.770446\n1 131242.472574\n2 131745.437889\n1 261920.593789\n2 323611.256365\n1 341693.666730\n2 378611.498102\n2 568433.562368\n1 667757.789581\n1 674662.040626\n2 690065.099817\n2 724737.429934\n1 774858.513301\n2 783681.914774\n1 808327.402925\n2 867697.070403\n1 880911.396984\n1 929807.064277\n2 942269.265950\n1 999503.792481\n",
   "20 15\n6 8719.787178\n10 13066.663722\n15 58623.690996\n9 184321.819759\n3 227999.294560\n2 279836.330518\n9 282806.308675\n8 311056.507765\n1 312315.562927\n5 459200.373445\n14 563454.265947\n7 647364.984868\n13 679761.613732\n4 684192.647497\n1 733119.607626\n7 748637.778398\n12 828048.945890\n11 893690.736585\n8 965323.895167\n5 967641.708962\n",
   "15 3\n1 0\n2 1\n3 2\n1 3\n2 4\n3 5\n1 6\n2 7\n3 8\n1 9\n2 10\n3 11\n1 12\n2 13\n3 14\n",
   "10 2\n2 0\n2 1\n2 2\n2 3\n2 4\n1 5\n1 6\n1 7\n1 8\n1 9\n",
   "11 3\n2 0\n2 1\n2 2\n2 3\n2 4\n3 5\n1 6\n1 7\n1 8\n1 9\n1 10\n"
  ],
  "outputs": [
   "1\n",
   "0\n",
   "2\n",
   "0\n",
   "1\n",
   "6\n",
   "5\n",
   "4\n",
   "2\n",
   "1\n",
   "1\n",
   "1\n",
   "9\n",
   "5\n",
   "4\n",
   "3\n",
   "6\n",
   "9\n",
   "15\n",
   "8\n",
   "5\n",
   "5\n"
  ]
 },
 {
  "id": "APPS-3765",
  "question": "In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are n extensions, the i-th of them multiplies the width or the length (by Arkady's choice) by a_{i}. Each extension can't be used more than once, the extensions can be used in any order.\n\nNow Arkady's field has size h × w. He wants to enlarge it so that it is possible to place a rectangle of size a × b on it (along the width or along the length, with sides parallel to the field sides). Find the minimum number of extensions needed to reach Arkady's goal.\n\n\n-----Input-----\n\nThe first line contains five integers a, b, h, w and n (1 ≤ a, b, h, w, n ≤ 100 000) — the sizes of the rectangle needed to be placed, the initial sizes of the field and the number of available extensions.\n\nThe second line contains n integers a_1, a_2, ..., a_{n} (2 ≤ a_{i} ≤ 100 000), where a_{i} equals the integer a side multiplies by when the i-th extension is applied.\n\n\n-----Output-----\n\nPrint the minimum number of extensions needed to reach Arkady's goal. If it is not possible to place the rectangle on the field with all extensions, print -1. If the rectangle can be placed on the initial field, print 0.\n\n\n-----Examples-----\nInput\n3 3 2 4 4\n2 5 4 10\n\nOutput\n1\n\nInput\n3 3 3 3 5\n2 3 5 4 2\n\nOutput\n0\n\nInput\n5 5 1 2 3\n2 2 3\n\nOutput\n-1\n\nInput\n3 4 1 1 3\n2 3 2\n\nOutput\n3\n\n\n\n-----Note-----\n\nIn the first example it is enough to use any of the extensions available. For example, we can enlarge h in 5 times using the second extension. Then h becomes equal 10 and it is now possible to place the rectangle on the field.",
  "inputs": [
   "3 3 2 4 4\n2 5 4 10\n",
   "3 3 3 3 5\n2 3 5 4 2\n",
   "5 5 1 2 3\n2 2 3\n",
   "3 4 1 1 3\n2 3 2\n",
   "572 540 6 2 12\n2 3 2 2 2 3 3 3 2 2 2 2\n",
   "375 905 1 1 17\n2 2 3 3 3 3 3 3 2 2 2 2 3 2 2 2 3\n",
   "37 23 4 1 16\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
   "20 19 6 8 18\n3 4 2 3 4 3 2 4 2 2 4 2 4 3 2 4 4 2\n",
   "11 11 5 3 11\n4 4 2 4 3 2 2 3 2 2 3\n",
   "100000 100000 1 1 100\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
   "642 694 4 7 15\n2 4 2 3 3 4 4 3 3 2 2 4 3 2 2\n",
   "100000 100000 1 1 2\n100000 99999\n",
   "100000 100000 99999 99999 2\n30000 30000\n",
   "41628 25266 1 1 36\n2 2 2 3 2 2 2 2 3 3 2 3 2 3 3 3 3 2 3 2 2 3 3 3 2 2 2 2 2 2 2 2 2 2 2 3\n",
   "34640 40496 1 1 107\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
   "32716 43645 4 1 102\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
   "63129 28077 1 1 31\n3 3 4 3 2 2 3 4 3 4 4 3 3 2 3 3 4 3 3 3 2 3 2 3 4 2 4 3 4 2 2\n",
   "11731 17857 6 7 21\n2 3 2 3 3 2 3 4 3 3 2 3 2 3 4 3 2 4 3 2 2\n",
   "82424 40643 9 2 200\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
   "1 1 1 1 1\n100000\n"
  ],
  "outputs": [
   "1\n",
   "0\n",
   "-1\n",
   "3\n",
   "-1\n",
   "14\n",
   "9\n",
   "2\n",
   "2\n",
   "34\n",
   "8\n",
   "-1\n",
   "2\n",
   "23\n",
   "32\n",
   "29\n",
   "13\n",
   "25\n",
   "16\n",
   "16\n",
   "25\n",
   "18\n",
   "14\n",
   "29\n",
   "0\n"
  ]
 },
 {
  "id": "APPS-3713",
  "question": "Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.\n\nHowever, all is not lost. Kevin is a big proponent of alternative thinking and believes that his score, instead of being the sum of his points, should be the length of the longest alternating subsequence of his string. Here, we define an alternating subsequence of a string as a not-necessarily contiguous subsequence where no two consecutive elements are equal. For example, {0, 1, 0, 1}, {1, 0, 1}, and {1, 0, 1, 0} are alternating sequences, while {1, 0, 0} and {0, 1, 0, 1, 1} are not.\n\nKevin, being the sneaky little puffball that he is, is willing to hack into the USAICO databases to improve his score. In order to be subtle, he decides that he will flip exactly one substring—that is, take a contiguous non-empty substring of his score and change all '0's in that substring to '1's and vice versa. After such an operation, Kevin wants to know the length of the longest possible alternating subsequence that his string could have.\n\n\n-----Input-----\n\nThe first line contains the number of questions on the olympiad n (1 ≤ n ≤ 100 000).\n\nThe following line contains a binary string of length n representing Kevin's results on the USAICO. \n\n\n-----Output-----\n\nOutput a single integer, the length of the longest possible alternating subsequence that Kevin can create in his string after flipping a single substring.\n\n\n-----Examples-----\nInput\n8\n10000011\n\nOutput\n5\n\nInput\n2\n01\n\nOutput\n2\n\n\n\n-----Note-----\n\nIn the first sample, Kevin can flip the bolded substring '10000011' and turn his string into '10011011', which has an alternating subsequence of length 5: '10011011'.\n\nIn the second sample, Kevin can flip the entire string and still have the same score.",
  "inputs": [
   "8\n10000011\n",
   "2\n01\n",
   "5\n10101\n",
   "75\n010101010101010101010101010101010101010101010101010101010101010101010101010\n",
   "11\n00000000000\n",
   "56\n10101011010101010101010101010101010101011010101010101010\n",
   "50\n01011010110101010101010101010101010101010101010100\n",
   "7\n0110100\n",
   "8\n11011111\n",
   "6\n000000\n",
   "5\n01000\n",
   "59\n10101010101010101010101010101010101010101010101010101010101\n",
   "88\n1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\n",
   "93\n010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\n",
   "70\n0101010101010101010101010101010101010101010101010101010101010101010101\n",
   "78\n010101010101010101010101010101101010101010101010101010101010101010101010101010\n",
   "83\n10101010101010101010101010101010101010101010101010110101010101010101010101010101010\n",
   "87\n101010101010101010101010101010101010101010101010101010101010101010101010101010010101010\n",
   "65\n01010101101010101010101010101010101010101010101010101010101010101\n",
   "69\n010101010101010101101010101010101010101010101010101010101010101010101\n",
   "74\n01010101010101010101010101010101010101010101010101010101010101000101010101\n",
   "77\n01010101010101001010101010101010100101010101010101010101010101010101010101010\n",
   "60\n101010110101010101010101010110101010101010101010101010101010\n",
   "89\n01010101010101010101010101010101010101010101010101010101101010101010101010100101010101010\n",
   "68\n01010101010101010101010101010101010100101010100101010101010100101010\n"
  ],
  "outputs": [
   "5\n",
   "2\n",
   "5\n",
   "75\n",
   "3\n",
   "56\n",
   "49\n",
   "7\n",
   "5\n",
   "3\n",
   "5\n",
   "59\n",
   "88\n",
   "93\n",
   "70\n",
   "78\n",
   "83\n",
   "87\n",
   "65\n",
   "69\n",
   "74\n",
   "77\n",
   "60\n",
   "89\n",
   "67\n"
  ]
 },
 {
  "id": "APPS-3841",
  "question": "In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must.\n\nLittle Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this...\n\nGiven two integers p and k, find a polynomial f(x) with non-negative integer coefficients strictly less than k, whose remainder is p when divided by (x + k). That is, f(x) = q(x)·(x + k) + p, where q(x) is a polynomial (not necessarily with integer coefficients).\n\n\n-----Input-----\n\nThe only line of input contains two space-separated integers p and k (1 ≤ p ≤ 10^18, 2 ≤ k ≤ 2 000).\n\n\n-----Output-----\n\nIf the polynomial does not exist, print a single integer -1, or output two lines otherwise.\n\nIn the first line print a non-negative integer d — the number of coefficients in the polynomial.\n\nIn the second line print d space-separated integers a_0, a_1, ..., a_{d} - 1, describing a polynomial $f(x) = \\sum_{i = 0}^{d - 1} a_{i} \\cdot x^{i}$ fulfilling the given requirements. Your output should satisfy 0 ≤ a_{i} < k for all 0 ≤ i ≤ d - 1, and a_{d} - 1 ≠ 0.\n\nIf there are many possible solutions, print any of them.\n\n\n-----Examples-----\nInput\n46 2\n\nOutput\n7\n0 1 0 0 1 1 1\n\nInput\n2018 214\n\nOutput\n3\n92 205 1\n\n\n\n-----Note-----\n\nIn the first example, f(x) = x^6 + x^5 + x^4 + x = (x^5 - x^4 + 3x^3 - 6x^2 + 12x - 23)·(x + 2) + 46.\n\nIn the second example, f(x) = x^2 + 205x + 92 = (x - 9)·(x + 214) + 2018.",
  "inputs": [
   "46 2\n",
   "2018 214\n",
   "4 2\n",
   "5 2\n",
   "10 3\n",
   "250 1958\n",
   "1000000000000000000 2000\n",
   "1 2\n",
   "2 2\n",
   "3 2\n",
   "6 2\n",
   "7 2\n",
   "8 2\n",
   "9 2\n",
   "10 2\n",
   "1 3\n",
   "2 3\n",
   "3 3\n",
   "4 3\n",
   "5 3\n",
   "6 3\n",
   "7 3\n",
   "8 3\n",
   "9 3\n",
   "462 2\n"
  ],
  "outputs": [
   "7\n0 1 0 0 1 1 1\n",
   "3\n92 205 1\n",
   "3\n0 0 1\n",
   "3\n1 0 1\n",
   "3\n1 0 1\n",
   "1\n250\n",
   "7\n0 0 0 0 500 1969 1\n",
   "1\n1\n",
   "3\n0 1 1\n",
   "3\n1 1 1\n",
   "5\n0 1 0 1 1\n",
   "5\n1 1 0 1 1\n",
   "5\n0 0 0 1 1\n",
   "5\n1 0 0 1 1\n",
   "5\n0 1 1 1 1\n",
   "1\n1\n",
   "1\n2\n",
   "3\n0 2 1\n",
   "3\n1 2 1\n",
   "3\n2 2 1\n",
   "3\n0 1 1\n",
   "3\n1 1 1\n",
   "3\n2 1 1\n",
   "3\n0 0 1\n",
   "11\n0 1 0 0 1 0 1 1 0 1 1\n"
  ]
 },
 {
  "id": "APPS-3764",
  "question": "Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now thinks that if he takes the bitwise XOR of strengths of some of rangers with his favourite number x, he might get soldiers of high strength. So, he decided to do the following operation k times: \n\n Arrange all the rangers in a straight line in the order of increasing strengths.\n\n Take the bitwise XOR (is written as $\\oplus$) of the strength of each alternate ranger with x and update it's strength.\n\n Suppose, Jon has 5 rangers with strengths [9, 7, 11, 15, 5] and he performs the operation 1 time with x = 2. He first arranges them in the order of their strengths, [5, 7, 9, 11, 15]. Then he does the following: \n\n The strength of first ranger is updated to $5 \\oplus 2$, i.e. 7.\n\n The strength of second ranger remains the same, i.e. 7.\n\n The strength of third ranger is updated to $9 \\oplus 2$, i.e. 11.\n\n The strength of fourth ranger remains the same, i.e. 11.\n\n The strength of fifth ranger is updated to $15 \\oplus 2$, i.e. 13.\n\n The new strengths of the 5 rangers are [7, 7, 11, 11, 13]\n\nNow, Jon wants to know the maximum and minimum strength of the rangers after performing the above operations k times. He wants your help for this task. Can you help him?\n\n\n-----Input-----\n\nFirst line consists of three integers n, k, x (1 ≤ n ≤ 10^5, 0 ≤ k ≤ 10^5, 0 ≤ x ≤ 10^3) — number of rangers Jon has, the number of times Jon will carry out the operation and Jon's favourite number respectively.\n\nSecond line consists of n integers representing the strengths of the rangers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^3).\n\n\n-----Output-----\n\nOutput two integers, the maximum and the minimum strength of the rangers after performing the operation k times.\n\n\n-----Examples-----\nInput\n5 1 2\n9 7 11 15 5\n\nOutput\n13 7\nInput\n2 100000 569\n605 986\n\nOutput\n986 605",
  "inputs": [
   "5 1 2\n9 7 11 15 5\n",
   "2 100000 569\n605 986\n",
   "10 10 98\n1 58 62 71 55 4 20 17 25 29\n",
   "100 100 96\n11 79 47 73 77 66 50 32 26 38 8 58 45 86 35 49 63 13 35 61 52 44 16 80 32 18 8 4 49 90 78 83 72 3 86 71 96 93 97 60 43 74 58 61 21 96 43 92 31 23 64 60 14 77 27 45 71 27 49 41 40 22 72 50 14 73 72 91 39 54 62 42 70 15 9 90 98 36 80 26 64 25 37 27 40 95 32 36 58 73 12 69 81 86 97 7 16 50 52 29\n",
   "100 100 301\n364 290 417 465 126 48 172 473 255 204 188 417 292 80 129 145 26 439 239 442 496 305 431 84 127 473 81 376 50 489 191 25 273 13 72 230 150 89 166 325 314 461 189 472 498 271 299 259 112 289 284 105 407 221 219 218 344 133 221 477 123 409 396 199 496 396 8 68 47 340 187 153 238 121 448 30 198 347 311 306 35 441 56 310 150 222 208 424 218 109 495 238 283 491 132 255 352 62 409 215\n",
   "10 50000 211\n613 668 383 487 696 540 157 86 440 22\n",
   "1 1 1\n1\n",
   "1 100000 489\n879\n",
   "1 100000 711\n882\n",
   "3 100000 993\n641 701 924\n",
   "5 3 64\n1 2 3 4 5\n",
   "1 1 100\n923\n",
   "2 101 2\n1 5\n",
   "4 3 2\n0 4 1 4\n",
   "10 3 77\n52 95 68 77 85 11 69 81 68 1\n",
   "5 2 2\n9 10 11 12 13\n",
   "2 1001 2\n1 5\n",
   "10 4 42\n87 40 11 62 83 30 91 10 13 72\n",
   "14 49 685\n104 88 54 134 251 977 691 713 471 591 109 69 898 696\n",
   "11 1007 9\n12 5 10 8 0 6 8 10 12 14 4\n",
   "10 22198 912\n188 111 569 531 824 735 857 433 182 39\n",
   "5 12 6\n0 2 2 2 3\n",
   "9 106 12\n1 11 12 14 18 20 23 24 26\n",
   "68 5430 49\n863 131 37 363 777 260 318 525 645 131 677 172 33 830 246 51 624 62 624 919 911 633 213 92 886 135 642 949 579 37 190 973 772 590 387 715 139 981 281 176 955 457 803 638 784 149 834 988 804 642 855 827 64 661 241 133 132 952 755 209 627 780 311 968 162 265 39 779\n",
   "28 97 49\n4 10 5 8 10 6 5 9 8 7 9 5 3 7 2 5 3 1 8 7 7 9 8 10 3 5 4 7\n"
  ],
  "outputs": [
   "13 7",
   "986 605",
   "127 17",
   "127 0",
   "509 9",
   "719 22",
   "0 0",
   "879 879",
   "882 882",
   "924 348",
   "69 3",
   "1023 1023",
   "5 3",
   "6 0",
   "121 9",
   "13 9",
   "5 3",
   "125 2",
   "977 54",
   "13 1",
   "1023 182",
   "4 0",
   "27 1",
   "1020 16",
   "59 2"
  ]
 },
 {
  "id": "APPS-3830",
  "question": "In the snake exhibition, there are $n$ rooms (numbered $0$ to $n - 1$) arranged in a circle, with a snake in each room. The rooms are connected by $n$ conveyor belts, and the $i$-th conveyor belt connects the rooms $i$ and $(i+1) \\bmod n$. In the other words, rooms $0$ and $1$, $1$ and $2$, $\\ldots$, $n-2$ and $n-1$, $n-1$ and $0$ are connected with conveyor belts.\n\nThe $i$-th conveyor belt is in one of three states:  If it is clockwise, snakes can only go from room $i$ to $(i+1) \\bmod n$.  If it is anticlockwise, snakes can only go from room $(i+1) \\bmod n$ to $i$.  If it is off, snakes can travel in either direction.  [Image] \n\nAbove is an example with $4$ rooms, where belts $0$ and $3$ are off, $1$ is clockwise, and $2$ is anticlockwise.\n\nEach snake wants to leave its room and come back to it later. A room is returnable if the snake there can leave the room, and later come back to it using the conveyor belts. How many such returnable rooms are there?\n\n\n-----Input-----\n\nEach test contains multiple test cases. The first line contains a single integer $t$ ($1 \\le t \\le 1000$): the number of test cases. The description of the test cases follows. \n\n The first line of each test case description contains a single integer $n$ ($2 \\le n \\le 300\\,000$): the number of rooms.\n\n The next line of each test case description contains a string $s$ of length $n$, consisting of only '<', '>' and '-'.  If $s_{i} = $ '>', the $i$-th conveyor belt goes clockwise.  If $s_{i} = $ '<', the $i$-th conveyor belt goes anticlockwise.  If $s_{i} = $ '-', the $i$-th conveyor belt is off. \n\nIt is guaranteed that the sum of $n$ among all test cases does not exceed $300\\,000$.\n\n\n-----Output-----\n\nFor each test case, output the number of returnable rooms.\n\n\n-----Example-----\nInput\n4\n4\n-><-\n5\n>>>>>\n3\n<--\n2\n<>\n\nOutput\n3\n5\n3\n0\n\n\n\n-----Note-----\n\nIn the first test case, all rooms are returnable except room $2$. The snake in the room $2$ is trapped and cannot exit. This test case corresponds to the picture from the problem statement.\n\n In the second test case, all rooms are returnable by traveling on the series of clockwise belts.",
  "inputs": [
   "4\n4\n-><-\n5\n>>>>>\n3\n<--\n2\n<>\n",
   "36\n2\n--\n2\n>-\n2\n<-\n2\n->\n2\n>>\n2\n<>\n2\n-<\n2\n><\n2\n<<\n3\n---\n3\n>--\n3\n<--\n3\n->-\n3\n>>-\n3\n<>-\n3\n-<-\n3\n><-\n3\n<<-\n3\n-->\n3\n>->\n3\n<->\n3\n->>\n3\n>>>\n3\n<>>\n3\n-<>\n3\n><>\n3\n<<>\n3\n--<\n3\n>-<\n3\n<-<\n3\n-><\n3\n>><\n3\n<><\n3\n-<<\n3\n><<\n3\n<<<\n",
   "1\n6\n<<->>-\n",
   "1\n5\n>>-<-\n",
   "1\n7\n-<<->>-\n",
   "1\n5\n>-<<-\n",
   "4\n5\n->>-<\n4\n-><-\n5\n>>>>>\n3\n<--\n",
   "1\n7\n->>-<<-\n",
   "1\n12\n->>>>--<<<<-\n",
   "1\n6\n->-<<-\n",
   "1\n5\n<->>-\n",
   "1\n15\n--->>>---<<<---\n",
   "1\n15\n-->>>>---<<<---\n",
   "1\n6\n->>-<-\n",
   "1\n6\n>>>-<-\n",
   "6\n5\n>-<<-\n5\n<->-<\n6\n>>-<<-\n6\n>-<<->\n7\n>>-<-<-\n7\n>>-<->-\n",
   "1\n7\n-->>-<-\n",
   "1\n7\n-->>--<\n",
   "1\n8\n--<<-->>\n",
   "1\n8\n<<-->>--\n",
   "1\n8\n>>--<<--\n",
   "1\n5\n->>-<\n",
   "1\n6\n>-<->>\n",
   "1\n24\n>>>----->>>>----<<<<----\n",
   "1\n6\n>>-<<-\n"
  ],
  "outputs": [
   "3\n5\n3\n0\n",
   "2\n2\n2\n2\n2\n0\n2\n0\n2\n3\n3\n3\n3\n3\n2\n3\n2\n3\n3\n3\n2\n3\n3\n0\n2\n0\n0\n3\n2\n3\n2\n0\n0\n3\n0\n3\n",
   "4\n",
   "4\n",
   "5\n",
   "4\n",
   "4\n3\n5\n3\n",
   "5\n",
   "6\n",
   "5\n",
   "4\n",
   "11\n",
   "10\n",
   "5\n",
   "4\n",
   "4\n4\n4\n4\n6\n6\n",
   "6\n",
   "6\n",
   "6\n",
   "6\n",
   "6\n",
   "4\n",
   "4\n",
   "16\n",
   "4\n"
  ]
 },
 {
  "id": "APPS-3692",
  "question": "Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.\n\nLittle Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve.\n\nA wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely.\n\n\n-----Input-----\n\nThe first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles.\n\nThe following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time.\n\n\n-----Output-----\n\nPrint a single integer — the number of regions on the plane.\n\n\n-----Examples-----\nInput\n3\n0 0 1\n2 0 1\n4 0 1\n\nOutput\n4\n\nInput\n3\n0 0 2\n3 0 2\n6 0 2\n\nOutput\n6\n\nInput\n3\n0 0 2\n2 0 2\n1 1 2\n\nOutput\n8\n\n\n\n-----Note-----\n\nFor the first example, $000$ \n\nFor the second example, [Image] \n\nFor the third example, $\\text{Q)}$",
  "inputs": [
   "3\n0 0 1\n2 0 1\n4 0 1\n",
   "3\n0 0 2\n3 0 2\n6 0 2\n",
   "3\n0 0 2\n2 0 2\n1 1 2\n",
   "1\n0 0 10\n",
   "2\n-10 10 1\n10 -10 1\n",
   "2\n-6 6 9\n3 -6 6\n",
   "2\n-10 -10 10\n10 10 10\n",
   "3\n-4 1 5\n-7 7 10\n-3 -4 8\n",
   "3\n-2 8 10\n3 -2 5\n3 1 3\n",
   "3\n0 0 2\n0 0 4\n3 0 2\n",
   "3\n8 5 7\n7 3 7\n5 2 5\n",
   "3\n-6 5 7\n1 -2 7\n7 9 7\n",
   "3\n1 -7 10\n-7 9 10\n-2 -1 4\n",
   "3\n-2 -3 5\n-6 1 7\n5 4 5\n",
   "3\n3 -2 7\n-1 2 5\n-4 1 3\n",
   "3\n4 5 10\n1 -1 5\n-1 -5 5\n",
   "3\n-1 0 5\n-2 1 5\n-5 4 7\n",
   "3\n-3 3 5\n1 -1 7\n2 5 10\n",
   "3\n-4 4 3\n5 6 4\n1 -5 9\n",
   "3\n-4 4 4\n2 4 2\n-1 0 6\n",
   "3\n-10 4 10\n10 4 10\n0 -7 10\n",
   "3\n-4 -5 3\n-3 -4 1\n-6 0 9\n",
   "3\n4 0 1\n-1 1 9\n0 3 6\n",
   "3\n-3 -2 3\n-4 -6 3\n-6 -4 9\n",
   "3\n-3 6 4\n-1 4 7\n0 2 1\n"
  ],
  "outputs": [
   "4\n",
   "6\n",
   "8\n",
   "2\n",
   "3\n",
   "3\n",
   "3\n",
   "8\n",
   "8\n",
   "6\n",
   "8\n",
   "8\n",
   "8\n",
   "7\n",
   "7\n",
   "6\n",
   "6\n",
   "7\n",
   "6\n",
   "7\n",
   "7\n",
   "4\n",
   "4\n",
   "5\n",
   "4\n"
  ]
 },
 {
  "id": "APPS-3833",
  "question": "The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp's schedule. After some continuous discussion, they came up with a schedule $s$, which can be represented as a binary string, in which the $i$-th symbol is '1' if students will write the contest in the $i$-th day and '0' if they will have a day off.\n\nAt the last moment Gleb said that the camp will be the most productive if it runs with the schedule $t$ (which can be described in the same format as schedule $s$). Since the number of days in the current may be different from number of days in schedule $t$, Gleb required that the camp's schedule must be altered so that the number of occurrences of $t$ in it as a substring is maximum possible. At the same time, the number of contest days and days off shouldn't change, only their order may change.\n\nCould you rearrange the schedule in the best possible way?\n\n\n-----Input-----\n\nThe first line contains string $s$ ($1 \\leqslant |s| \\leqslant 500\\,000$), denoting the current project of the camp's schedule.\n\nThe second line contains string $t$ ($1 \\leqslant |t| \\leqslant 500\\,000$), denoting the optimal schedule according to Gleb.\n\nStrings $s$ and $t$ contain characters '0' and '1' only.\n\n\n-----Output-----\n\nIn the only line print the schedule having the largest number of substrings equal to $t$. Printed schedule should consist of characters '0' and '1' only and the number of zeros should be equal to the number of zeros in $s$ and the number of ones should be equal to the number of ones in $s$.\n\nIn case there multiple optimal schedules, print any of them.\n\n\n-----Examples-----\nInput\n101101\n110\n\nOutput\n110110\nInput\n10010110\n100011\n\nOutput\n01100011\n\nInput\n10\n11100\n\nOutput\n01\n\n\n-----Note-----\n\nIn the first example there are two occurrences, one starting from first position and one starting from fourth position.\n\nIn the second example there is only one occurrence, which starts from third position. Note, that the answer is not unique. For example, if we move the first day (which is a day off) to the last position, the number of occurrences of $t$ wouldn't change.\n\nIn the third example it's impossible to make even a single occurrence.",
  "inputs": [
   "101101\n110\n",
   "10010110\n100011\n",
   "10\n11100\n",
   "11000000\n0\n",
   "10100110\n10\n",
   "10101000\n101\n",
   "11010010\n11010\n",
   "00101010\n01101011\n",
   "11111111\n1\n",
   "11011000\n10\n",
   "11111111\n0000\n",
   "11111111\n1111\n",
   "11111111\n11111110\n",
   "11100100\n01101001\n",
   "10000111100011111100010100110001100110011100001100\n0001000011101001110111011\n",
   "01001101001011100000100110001010010010111101100100\n00001000010011010011111000001111000011011101011000\n",
   "00000000000000000000000000000000000000000000000000\n000000000000000000000000000000\n",
   "10000111\n10101\n",
   "00000000000000000000000000000000000000000000000000\n111111111111111111111111111111\n",
   "01110100\n101\n",
   "11011000\n11010\n",
   "00010101\n00101010\n",
   "00000000\n0000\n",
   "00000000\n1111\n",
   "11001111111000110010000001011001001011111101110110\n1\n"
  ],
  "outputs": [
   "110110",
   "10001101",
   "01",
   "00000011",
   "10101010",
   "10101000",
   "11010001",
   "01011000",
   "11111111",
   "10101010",
   "11111111",
   "11111111",
   "11111111",
   "01101001",
   "00010000111010011101110110000000000000011111111111",
   "00001000010011010011111000001111000011011101011000",
   "00000000000000000000000000000000000000000000000000",
   "10101010",
   "00000000000000000000000000000000000000000000000000",
   "10101010",
   "11010001",
   "00101010",
   "00000000",
   "00000000",
   "11111111111111111111111111110000000000000000000000"
  ]
 },
 {
  "id": "APPS-3981",
  "question": "After the war, the supersonic rocket became the most common public transportation.\n\nEach supersonic rocket consists of two \"engines\". Each engine is a set of \"power sources\". The first engine has $n$ power sources, and the second one has $m$ power sources. A power source can be described as a point $(x_i, y_i)$ on a 2-D plane. All points in each engine are different.\n\nYou can manipulate each engine separately. There are two operations that you can do with each engine. You can do each operation as many times as you want. For every power source as a whole in that engine: $(x_i, y_i)$ becomes $(x_i+a, y_i+b)$, $a$ and $b$ can be any real numbers. In other words, all power sources will be shifted. For every power source as a whole in that engine: $(x_i, y_i)$ becomes $(x_i \\cos \\theta - y_i \\sin \\theta, x_i \\sin \\theta + y_i \\cos \\theta)$, $\\theta$ can be any real number. In other words, all power sources will be rotated.\n\nThe engines work as follows: after the two engines are powered, their power sources are being combined (here power sources of different engines may coincide). If two power sources $A(x_a, y_a)$ and $B(x_b, y_b)$ exist, then for all real number $k$ that $0 \\lt k \\lt 1$, a new power source will be created $C_k(kx_a+(1-k)x_b,ky_a+(1-k)y_b)$. Then, this procedure will be repeated again with all new and old power sources. After that, the \"power field\" from all power sources will be generated (can be considered as an infinite set of all power sources occurred).\n\nA supersonic rocket is \"safe\" if and only if after you manipulate the engines, destroying any power source and then power the engine, the power field generated won't be changed (comparing to the situation where no power source erased). Two power fields are considered the same if and only if any power source in one field belongs to the other one as well.\n\nGiven a supersonic rocket, check whether it is safe or not.\n\n\n-----Input-----\n\nThe first line contains two integers $n$, $m$ ($3 \\le n, m \\le 10^5$) — the number of power sources in each engine.\n\nEach of the next $n$ lines contains two integers $x_i$ and $y_i$ ($0\\leq x_i, y_i\\leq 10^8$) — the coordinates of the $i$-th power source in the first engine.\n\nEach of the next $m$ lines contains two integers $x_i$ and $y_i$ ($0\\leq x_i, y_i\\leq 10^8$) — the coordinates of the $i$-th power source in the second engine.\n\nIt is guaranteed that there are no two or more power sources that are located in the same point in each engine.\n\n\n-----Output-----\n\nPrint \"YES\" if the supersonic rocket is safe, otherwise \"NO\".\n\nYou can print each letter in an arbitrary case (upper or lower).\n\n\n-----Examples-----\nInput\n3 4\n0 0\n0 2\n2 0\n0 2\n2 2\n2 0\n1 1\n\nOutput\nYES\n\nInput\n3 4\n0 0\n0 2\n2 0\n0 2\n2 2\n2 0\n0 0\n\nOutput\nNO\n\n\n\n-----Note-----\n\nThe first sample: [Image] Those near pairs of blue and orange points actually coincide. \n\nFirst, manipulate the first engine: use the second operation with $\\theta = \\pi$ (to rotate all power sources $180$ degrees).\n\nThe power sources in the first engine become $(0, 0)$, $(0, -2)$, and $(-2, 0)$. [Image] \n\nSecond, manipulate the second engine: use the first operation with $a = b = -2$.\n\nThe power sources in the second engine become $(-2, 0)$, $(0, 0)$, $(0, -2)$, and $(-1, -1)$. [Image] \n\nYou can examine that destroying any point, the power field formed by the two engines are always the solid triangle $(0, 0)$, $(-2, 0)$, $(0, -2)$.\n\nIn the second sample, no matter how you manipulate the engines, there always exists a power source in the second engine that power field will shrink if you destroy it.",
  "inputs": [
   "3 4\n0 0\n0 2\n2 0\n0 2\n2 2\n2 0\n1 1\n",
   "3 4\n0 0\n0 2\n2 0\n0 2\n2 2\n2 0\n0 0\n",
   "8 8\n53212775 61830464\n32047271 31958754\n46845363 47341547\n46097536 79640734\n25559819 90360169\n5442822 40309249\n57656501 31139219\n1191345 7784770\n61052639 71686018\n53542361 10165576\n61963163 25946318\n15498921 83261369\n97981085 40697107\n35269685 20583089\n50275077 3751318\n40877349 23290816\n",
   "10 8\n1446 2090916\n0 0\n1060 1123600\n2939 8946081\n1405 8946081\n2842 8946081\n2979 8946081\n2850 8946081\n0 100000000\n2991 8946081\n1446 2090916\n0 0\n1060 1123600\n2575 8946081\n1586 8946081\n460 8946081\n0 100000000\n2991 8946081\n",
   "8 9\n4965 24651225\n0 0\n0 36000000\n5004 25040016\n4354 30107169\n1309 30107169\n2301 30107169\n5487 30107169\n30107169 513\n30107169 2849\n30107169 998\n25040016 996\n30107169 2249\n30107169 1567\n36000000 6000\n0 6000\n24651225 1035\n",
   "3 3\n0 100000000\n0 0\n100000000 0\n100000000 100000000\n100000000 0\n0 100000000\n",
   "3 3\n1 1\n2 2\n3 3\n0 10\n1 9\n2 8\n",
   "3 3\n1 1\n2 2\n3 3\n2 2\n6 6\n7 7\n",
   "3 3\n1 1\n2 2\n3 3\n1 1\n1 2\n1 3\n",
   "4 4\n0 5\n5 10\n5 0\n10 5\n0 1\n7 2\n14 1\n7 0\n",
   "3 3\n0 0\n100000000 0\n100000000 1\n100000000 100000000\n0 100000000\n0 99999999\n",
   "4 3\n0 0\n100000000 0\n100000000 2\n50000000 1\n100000000 100000000\n0 100000000\n0 99999998\n",
   "4 3\n0 0\n100000000 0\n100000000 2\n50000001 1\n100000000 100000000\n0 100000000\n0 99999998\n",
   "4 3\n0 0\n100000000 0\n100000000 2\n49999999 1\n100000000 100000000\n0 100000000\n0 99999998\n",
   "6 3\n0 0\n1 1\n2 2\n3 3\n4 4\n6 6\n0 6\n3 3\n6 0\n",
   "6 3\n0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n0 6\n3 3\n6 0\n",
   "5 5\n2 0\n0 4\n4 8\n8 4\n10 0\n0 2\n2 6\n6 10\n10 6\n8 2\n",
   "8 8\n0 1\n0 3\n1 4\n3 4\n4 3\n4 1\n3 0\n1 0\n2 5\n3 5\n5 3\n5 2\n3 0\n2 0\n0 2\n0 3\n",
   "6 6\n2 0\n4 0\n6 1\n4 2\n2 2\n0 1\n1 0\n3 0\n4 2\n3 4\n1 4\n0 2\n",
   "4 4\n0 0\n0 5\n5 0\n5 5\n0 3\n4 0\n7 4\n3 7\n",
   "4 4\n0 0\n1 0\n1 1\n2 1\n0 1\n1 1\n1 0\n2 0\n"
  ],
  "outputs": [
   "YES\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "NO\n"
  ]
 },
 {
  "id": "APPS-3723",
  "question": "Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.\n\nBut Zulu warns him that a group of k > 1 Pokemon with strengths {s_1, s_2, s_3, ..., s_{k}} tend to fight among each other if gcd(s_1, s_2, s_3, ..., s_{k}) = 1 (see notes for gcd definition).\n\nBash, being smart, does not want his Pokemon to fight among each other. However, he also wants to maximize the number of Pokemon he takes from the lab. Can you help Bash find out the maximum number of Pokemon he can take? \n\nNote: A Pokemon cannot fight with itself.\n\n\n-----Input-----\n\nThe input consists of two lines.\n\nThe first line contains an integer n (1 ≤ n ≤ 10^5), the number of Pokemon in the lab.\n\nThe next line contains n space separated integers, where the i-th of them denotes s_{i} (1 ≤ s_{i} ≤ 10^5), the strength of the i-th Pokemon.\n\n\n-----Output-----\n\nPrint single integer — the maximum number of Pokemons Bash can take.\n\n\n-----Examples-----\nInput\n3\n2 3 4\n\nOutput\n2\n\nInput\n5\n2 3 4 6 7\n\nOutput\n3\n\n\n\n-----Note-----\n\ngcd (greatest common divisor) of positive integers set {a_1, a_2, ..., a_{n}} is the maximum positive integer that divides all the integers {a_1, a_2, ..., a_{n}}.\n\nIn the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.\n\nIn the second sample, we can take Pokemons with strengths {2, 4, 6}, and there is no larger group with gcd ≠ 1.",
  "inputs": [
   "3\n2 3 4\n",
   "5\n2 3 4 6 7\n",
   "3\n5 6 4\n",
   "8\n41 74 4 27 85 39 100 36\n",
   "6\n89 20 86 81 62 23\n",
   "71\n23 84 98 8 14 4 42 56 83 87 28 22 32 50 5 96 90 1 59 74 77 88 71 38 62 36 85 97 99 6 81 20 49 57 66 9 45 41 29 68 35 19 27 76 78 72 55 25 46 48 26 53 39 31 94 34 63 37 64 16 79 24 82 17 12 3 89 61 80 30 10\n",
   "95\n72 38 75 62 87 30 11 65 35 16 73 23 18 48 19 4 22 42 14 60 49 83 59 15 51 27 80 97 37 100 64 81 54 71 52 20 5 98 78 86 26 55 25 57 36 3 8 74 82 21 29 1 76 2 79 61 39 9 89 77 70 63 56 28 92 53 31 45 93 47 67 99 58 12 84 44 32 34 69 40 13 7 66 68 17 85 6 90 33 91 94 24 46 10 50\n",
   "44\n39706 21317 26213 55086 10799 31825 29024 6565 96535 11412 14642 91901 41932 24538 81351 53861 63403 34199 82286 32594 29684 42753 16857 73821 71085 36306 70080 11233 21023 8551 85406 95390 92375 52675 77938 46265 74855 5229 5856 66713 65730 24525 84078 20684\n",
   "35\n45633 86983 46174 48399 33926 51395 76300 6387 48852 82808 28694 79864 4482 35982 21956 76522 19656 74518 28480 71481 25700 46815 14170 95705 8535 96993 29029 8898 97637 62710 14615 22864 69849 27068 68557\n",
   "1\n1\n",
   "10\n10 7 9 8 3 3 10 7 3 3\n",
   "9\n10 10 6 10 9 1 8 3 5\n",
   "7\n9 4 2 3 3 9 8\n",
   "1\n4\n",
   "6\n1623 45906 37856 34727 27156 12598\n",
   "30\n83172 59163 67334 83980 5932 8773 77649 41428 62789 28159 17183 10199 41496 59500 14614 10468 54886 64679 42382 57021 50499 95643 77239 61434 16181 30505 59152 55972 18265 70566\n",
   "23\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 22 16 2 13 16\n",
   "46\n12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 12553 15 1 18 28 20 6 31 16 5 23 21 38 3 11 18 11 3 25 33\n",
   "43\n8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8831 8 23 40 33 11 5 21 16 19 15 41 30 28 31 5 32 16 5 38 11 21 34\n",
   "25\n58427 26687 48857 46477 7039 25423 58757 48119 38113 40637 22391 48337 4157 10597 8167 19031 64613 70913 69313 18047 17159 77491 13499 70949 24107\n",
   "10\n1 1 1 1 1 1 1 1 1 1\n",
   "2\n3 6\n",
   "5\n1 1 1 1 1\n",
   "5\n3 3 3 3 3\n",
   "3\n1 1 1\n"
  ],
  "outputs": [
   "2\n",
   "3\n",
   "2\n",
   "4\n",
   "3\n",
   "38\n",
   "48\n",
   "19\n",
   "20\n",
   "1\n",
   "5\n",
   "5\n",
   "4\n",
   "1\n",
   "4\n",
   "15\n",
   "22\n",
   "27\n",
   "21\n",
   "1\n",
   "1\n",
   "2\n",
   "1\n",
   "5\n",
   "1\n"
  ]
 },
 {
  "id": "APPS-3690",
  "question": "Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.\n\nThe entire universe turned into an enormous clock face with three hands — hour, minute, and second. Time froze, and clocks now show the time h hours, m minutes, s seconds.\n\nLast time Misha talked with the coordinator at t_1 o'clock, so now he stands on the number t_1 on the clock face. The contest should be ready by t_2 o'clock. In the terms of paradox it means that Misha has to go to number t_2 somehow. Note that he doesn't have to move forward only: in these circumstances time has no direction.\n\nClock hands are very long, and Misha cannot get round them. He also cannot step over as it leads to the collapse of space-time. That is, if hour clock points 12 and Misha stands at 11 then he cannot move to 1 along the top arc. He has to follow all the way round the clock center (of course, if there are no other hands on his way).\n\nGiven the hands' positions, t_1, and t_2, find if Misha can prepare the contest on time (or should we say on space?). That is, find if he can move from t_1 to t_2 by the clock face.\n\n\n-----Input-----\n\nFive integers h, m, s, t_1, t_2 (1 ≤ h ≤ 12, 0 ≤ m, s ≤ 59, 1 ≤ t_1, t_2 ≤ 12, t_1 ≠ t_2).\n\nMisha's position and the target time do not coincide with the position of any hand.\n\n\n-----Output-----\n\nPrint \"YES\" (quotes for clarity), if Misha can prepare the contest on time, and \"NO\" otherwise.\n\nYou can print each character either upper- or lowercase (\"YeS\" and \"yes\" are valid when the answer is \"YES\").\n\n\n-----Examples-----\nInput\n12 30 45 3 11\n\nOutput\nNO\n\nInput\n12 0 1 12 1\n\nOutput\nYES\n\nInput\n3 47 0 4 9\n\nOutput\nYES\n\n\n\n-----Note-----\n\nThe three examples are shown on the pictures below from left to right. The starting position of Misha is shown with green, the ending position is shown with pink. Note that the positions of the hands on the pictures are not exact, but are close to the exact and the answer is the same. $\\oplus 0 \\theta$",
  "inputs": [
   "12 30 45 3 11\n",
   "12 0 1 12 1\n",
   "3 47 0 4 9\n",
   "10 22 59 6 10\n",
   "3 1 13 12 3\n",
   "11 19 28 9 10\n",
   "9 38 22 6 1\n",
   "5 41 11 5 8\n",
   "11 2 53 10 4\n",
   "9 41 17 10 1\n",
   "6 54 48 12 6\n",
   "12 55 9 5 1\n",
   "8 55 35 9 3\n",
   "3 21 34 3 10\n",
   "2 52 1 12 3\n",
   "7 17 11 1 7\n",
   "11 6 37 6 4\n",
   "9 6 22 8 1\n",
   "3 10 5 5 9\n",
   "7 12 22 11 2\n",
   "7 19 4 7 3\n",
   "11 36 21 4 6\n",
   "10 32 49 1 3\n",
   "1 9 43 11 3\n",
   "1 8 33 4 8\n"
  ],
  "outputs": [
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "NO\n"
  ]
 },
 {
  "id": "APPS-3722",
  "question": "Given are an integer N and four characters c_{\\mathrm{AA}}, c_{\\mathrm{AB}}, c_{\\mathrm{BA}}, and c_{\\mathrm{BB}}.\nHere, it is guaranteed that each of those four characters is A or B.\nSnuke has a string s, which is initially AB.\nLet |s| denote the length of s.\nSnuke can do the four kinds of operations below zero or more times in any order:\n - Choose i such that 1 \\leq i < |s|, s_{i} = A, s_{i+1} = A and insert c_{\\mathrm{AA}} between the i-th and (i+1)-th characters of s.\n - Choose i such that 1 \\leq i < |s|, s_{i} = A, s_{i+1} = B and insert c_{\\mathrm{AB}} between the i-th and (i+1)-th characters of s.\n - Choose i such that 1 \\leq i < |s|, s_{i} = B, s_{i+1} = A and insert c_{\\mathrm{BA}} between the i-th and (i+1)-th characters of s.\n - Choose i such that 1 \\leq i < |s|, s_{i} = B, s_{i+1} = B and insert c_{\\mathrm{BB}} between the i-th and (i+1)-th characters of s.\nFind the number, modulo (10^9+7), of strings that can be s when Snuke has done the operations so that the length of s becomes N.\n\n-----Constraints-----\n - 2 \\leq N \\leq 1000\n - Each of c_{\\mathrm{AA}}, c_{\\mathrm{AB}}, c_{\\mathrm{BA}}, and c_{\\mathrm{BB}} is A or B.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nc_{\\mathrm{AA}}\nc_{\\mathrm{AB}}\nc_{\\mathrm{BA}}\nc_{\\mathrm{BB}}\n\n-----Output-----\nPrint the number, modulo (10^9+7), of strings that can be s when Snuke has done the operations so that the length of s becomes N.\n\n-----Sample Input-----\n4\nA\nB\nB\nA\n\n-----Sample Output-----\n2\n\n - There are two strings that can be s when Snuke is done: ABAB and ABBB.",
  "inputs": [
   "4\nA\nB\nB\nA\n",
   "1000\nB\nB\nB\nB\n",
   "2\nB\nA\nA\nA\n",
   "2\nA\nB\nA\nA\n",
   "2\nB\nB\nA\nA\n",
   "2\nA\nA\nB\nA\n",
   "2\nB\nA\nB\nA\n",
   "2\nA\nB\nB\nA\n",
   "2\nB\nB\nB\nA\n",
   "2\nA\nA\nA\nB\n",
   "2\nB\nA\nA\nB\n",
   "2\nA\nB\nA\nB\n",
   "2\nB\nB\nA\nB\n",
   "2\nA\nA\nB\nB\n",
   "2\nB\nA\nB\nB\n",
   "2\nA\nB\nB\nB\n",
   "2\nB\nB\nB\nB\n",
   "2\nA\nA\nA\nA\n",
   "3\nB\nA\nA\nA\n",
   "3\nA\nB\nA\nA\n",
   "3\nB\nB\nA\nA\n",
   "3\nA\nA\nB\nA\n",
   "3\nB\nA\nB\nA\n",
   "3\nA\nB\nB\nA\n",
   "3\nB\nB\nB\nA\n"
  ],
  "outputs": [
   "2\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n",
   "1\n"
  ]
 },
 {
  "id": "APPS-3718",
  "question": "Limak is a little polar bear. He has n balls, the i-th ball has size t_{i}.\n\nLimak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy:  No two friends can get balls of the same size.  No two friends can get balls of sizes that differ by more than 2. \n\nFor example, Limak can choose balls with sizes 4, 5 and 3, or balls with sizes 90, 91 and 92. But he can't choose balls with sizes 5, 5 and 6 (two friends would get balls of the same size), and he can't choose balls with sizes 30, 31 and 33 (because sizes 30 and 33 differ by more than 2).\n\nYour task is to check whether Limak can choose three balls that satisfy conditions above.\n\n\n-----Input-----\n\nThe first line of the input contains one integer n (3 ≤ n ≤ 50) — the number of balls Limak has.\n\nThe second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 1000) where t_{i} denotes the size of the i-th ball.\n\n\n-----Output-----\n\nPrint \"YES\" (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than 2. Otherwise, print \"NO\" (without quotes).\n\n\n-----Examples-----\nInput\n4\n18 55 16 17\n\nOutput\nYES\n\nInput\n6\n40 41 43 44 44 44\n\nOutput\nNO\n\nInput\n8\n5 972 3 4 1 4 970 971\n\nOutput\nYES\n\n\n\n-----Note-----\n\nIn the first sample, there are 4 balls and Limak is able to choose three of them to satisfy the rules. He must must choose balls with sizes 18, 16 and 17.\n\nIn the second sample, there is no way to give gifts to three friends without breaking the rules.\n\nIn the third sample, there is even more than one way to choose balls:  Choose balls with sizes 3, 4 and 5.  Choose balls with sizes 972, 970, 971.",
  "inputs": [
   "4\n18 55 16 17\n",
   "6\n40 41 43 44 44 44\n",
   "8\n5 972 3 4 1 4 970 971\n",
   "3\n959 747 656\n",
   "4\n1 2 2 3\n",
   "50\n998 30 384 289 505 340 872 223 663 31 929 625 864 699 735 589 676 399 745 635 963 381 75 97 324 612 597 797 103 382 25 894 219 458 337 572 201 355 294 275 278 311 586 573 965 704 936 237 715 543\n",
   "50\n941 877 987 982 966 979 984 810 811 909 872 980 957 897 845 995 924 905 984 914 824 840 868 910 815 808 872 858 883 952 823 835 860 874 959 972 931 867 866 987 982 837 800 921 887 910 982 980 828 869\n",
   "3\n408 410 409\n",
   "3\n903 902 904\n",
   "3\n399 400 398\n",
   "3\n450 448 449\n",
   "3\n390 389 388\n",
   "3\n438 439 440\n",
   "11\n488 688 490 94 564 615 641 170 489 517 669\n",
   "24\n102 672 983 82 720 501 81 721 982 312 207 897 159 964 611 956 118 984 37 271 596 403 772 954\n",
   "36\n175 551 70 479 875 480 979 32 465 402 640 116 76 687 874 678 359 785 753 401 978 629 162 963 886 641 39 845 132 930 2 372 478 947 407 318\n",
   "6\n10 79 306 334 304 305\n",
   "34\n787 62 26 683 486 364 684 891 846 801 969 837 359 800 836 359 471 637 732 91 841 836 7 799 959 405 416 841 737 803 615 483 323 365\n",
   "30\n860 238 14 543 669 100 428 789 576 484 754 274 849 850 586 377 711 386 510 408 520 693 23 477 266 851 728 711 964 73\n",
   "11\n325 325 324 324 324 325 325 324 324 324 324\n",
   "7\n517 517 518 517 518 518 518\n",
   "20\n710 710 711 711 711 711 710 710 710 710 711 710 710 710 710 710 710 711 711 710\n",
   "48\n29 30 29 29 29 30 29 30 30 30 30 29 30 30 30 29 29 30 30 29 30 29 29 30 29 30 29 30 30 29 30 29 29 30 30 29 29 30 30 29 29 30 30 30 29 29 30 29\n",
   "7\n880 880 514 536 881 881 879\n",
   "15\n377 432 262 376 261 375 377 262 263 263 261 376 262 262 375\n"
  ],
  "outputs": [
   "YES\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "NO\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "YES\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "NO\n",
   "YES\n",
   "YES\n"
  ]
 },
 {
  "id": "APPS-3731",
  "question": "Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.\n\nAll characters in this game are lowercase English letters. There are two players: Mister B and his competitor.\n\nInitially the players have a string s consisting of the first a English letters in alphabetical order (for example, if a = 5, then s equals to \"abcde\").\n\nThe players take turns appending letters to string s. Mister B moves first.\n\nMister B must append exactly b letters on each his move. He can arbitrary choose these letters. His opponent adds exactly a letters on each move.\n\nMister B quickly understood that his opponent was just a computer that used a simple algorithm. The computer on each turn considers the suffix of string s of length a and generates a string t of length a such that all letters in the string t are distinct and don't appear in the considered suffix. From multiple variants of t lexicographically minimal is chosen (if a = 4 and the suffix is \"bfdd\", the computer chooses string t equal to \"aceg\"). After that the chosen string t is appended to the end of s.\n\nMister B soon found the game boring and came up with the following question: what can be the minimum possible number of different letters in string s on the segment between positions l and r, inclusive. Letters of string s are numerated starting from 1.\n\n\n-----Input-----\n\nFirst and only line contains four space-separated integers: a, b, l and r (1 ≤ a, b ≤ 12, 1 ≤ l ≤ r ≤ 10^9) — the numbers of letters each player appends and the bounds of the segment.\n\n\n-----Output-----\n\nPrint one integer — the minimum possible number of different letters in the segment from position l to position r, inclusive, in string s.\n\n\n-----Examples-----\nInput\n1 1 1 8\n\nOutput\n2\nInput\n4 2 2 6\n\nOutput\n3\nInput\n3 7 4 6\n\nOutput\n1\n\n\n-----Note-----\n\nIn the first sample test one of optimal strategies generate string s = \"abababab...\", that's why answer is 2.\n\nIn the second sample test string s = \"abcdbcaefg...\" can be obtained, chosen segment will look like \"bcdbc\", that's why answer is 3.\n\nIn the third sample test string s = \"abczzzacad...\" can be obtained, chosen, segment will look like \"zzz\", that's why answer is 1.",
  "inputs": [
   "1 1 1 8\n",
   "4 2 2 6\n",
   "3 7 4 6\n",
   "4 5 1 1\n",
   "12 12 1 1000\n",
   "12 1 1000 1000\n",
   "3 4 701 703\n",
   "12 12 13 1000000000\n",
   "3 4 999999999 1000000000\n",
   "5 6 1000000000 1000000000\n",
   "1 1 1 1\n",
   "12 1 100000011 100000024\n",
   "10 12 220000011 220000032\n",
   "1 1 1 1000000000\n",
   "1 1 999999999 1000000000\n",
   "1 1 1000000000 1000000000\n",
   "12 12 1 24\n",
   "12 12 876543210 1000000000\n",
   "5 11 654321106 654321117\n",
   "5 11 654321117 654321140\n",
   "9 12 654321114 654321128\n",
   "5 12 654321101 654321140\n",
   "2 12 654321104 654321122\n",
   "6 1 654321100 654321115\n",
   "2 1 654321122 654321129\n"
  ],
  "outputs": [
   "2",
   "3",
   "1",
   "1",
   "13",
   "1",
   "3",
   "13",
   "1",
   "1",
   "1",
   "13",
   "11",
   "2",
   "1",
   "1",
   "12",
   "13",
   "4",
   "6",
   "4",
   "6",
   "3",
   "11",
   "3"
  ]
 },
 {
  "id": "APPS-3805",
  "question": "Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.\n\nThe device is powered by two wires \"plus\" and \"minus\". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view): [Image] \n\nMike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the \"plus\" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.\n\nTo understand the problem better please read the notes to the test samples.\n\n\n-----Input-----\n\nThe single line of the input contains a sequence of characters \"+\" and \"-\" of length n (1 ≤ n ≤ 100000). The i-th (1 ≤ i ≤ n) position of the sequence contains the character \"+\", if on the i-th step from the wall the \"plus\" wire runs above the \"minus\" wire, and the character \"-\" otherwise.\n\n\n-----Output-----\n\nPrint either \"Yes\" (without the quotes) if the wires can be untangled or \"No\" (without the quotes) if the wires cannot be untangled.\n\n\n-----Examples-----\nInput\n-++-\n\nOutput\nYes\n\nInput\n+-\n\nOutput\nNo\n\nInput\n++\n\nOutput\nYes\n\nInput\n-\n\nOutput\nNo\n\n\n\n-----Note-----\n\nThe first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the \"plus\" wire lower, thus eliminating the two crosses in the middle, and then draw it under the \"minus\" wire, eliminating also the remaining two crosses.\n\nIn the second testcase the \"plus\" wire makes one full revolution around the \"minus\" wire. Thus the wires cannot be untangled:  [Image] \n\nIn the third testcase the \"plus\" wire simply runs above the \"minus\" wire twice in sequence. The wires can be untangled by lifting \"plus\" and moving it higher:  [Image] \n\nIn the fourth testcase the \"minus\" wire runs above the \"plus\" wire once. The wires cannot be untangled without moving the device itself:  [Image]",
  "inputs": [
   "-++-\n",
   "+-\n",
   "++\n",
   "-\n",
   "+-+-\n",
   "-+-\n",
   "-++-+--+\n",
   "+\n",
   "-+\n",
   "--\n",
   "+++\n",
   "--+\n",
   "++--++\n",
   "+-++-+\n",
   "+-+--+\n",
   "--++-+\n",
   "-+-+--\n",
   "+-+++-\n",
   "-+-+-+\n",
   "-++-+--++--+-++-\n",
   "+-----+-++---+------+++-++++\n",
   "-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+--++-----+--+-++---+++---++----+++-++++--++-++-\n",
   "-+-----++++--++-+-++\n",
   "+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++--+-+++--++-+-+++-++--+++-++++++++++-++-++++++-+++--+--++-+++--+++-++++----+++---+-+----++++-+-+\n",
   "-+-+-++-+-+-\n"
  ],
  "outputs": [
   "Yes\n",
   "No\n",
   "Yes\n",
   "No\n",
   "No\n",
   "No\n",
   "Yes\n",
   "No\n",
   "No\n",
   "Yes\n",
   "No\n",
   "No\n",
   "Yes\n",
   "Yes\n",
   "No\n",
   "No\n",
   "No\n",
   "No\n",
   "No\n",
   "Yes\n",
   "No\n",
   "No\n",
   "Yes\n",
   "Yes\n",
   "Yes\n"
  ]
 }
]