[ { "id": "2063/B", "aliases": null, "contest_id": "2063", "contest_name": "Codeforces Round 1000 (Div. 2)", "contest_type": "CF", "contest_start": 1737547500, "contest_start_year": 2025, "index": "B", "time_limit": 1.5, "memory_limit": 256.0, "title": "Subsequence Update", "description": "After Little John borrowed expansion screws from auntie a few hundred times, eventually she decided to come and take back the unused ones.But as they are a crucial part of home design, Little John decides to hide some in the most unreachable places — under the eco-friendly wood veneers.\n\nYou are given an integer sequence $$$a_1, a_2, \\ldots, a_n$$$, and a segment $$$[l,r]$$$ ($$$1 \\le l \\le r \\le n$$$).\n\nYou must perform the following operation on the sequence exactly once.\n\n- Choose any subsequence$$$^{\\text{∗}}$$$ of the sequence $$$a$$$, and reverse it. Note that the subsequence does not have to be contiguous.\n\nFormally, choose any number of indices $$$i_1,i_2,\\ldots,i_k$$$ such that $$$1 \\le i_1 < i_2 < \\ldots < i_k \\le n$$$. Then, change the $$$i_x$$$-th element to the original value of the $$$i_{k-x+1}$$$-th element simultaneously for all $$$1 \\le x \\le k$$$.\n\nFind the minimum value of $$$a_l+a_{l+1}+\\ldots+a_{r-1}+a_r$$$ after performing the operation.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.\n\nThe first line of each test case contains three integers $$$n$$$, $$$l$$$, $$$r$$$ ($$$1 \\le l \\le r \\le n \\le 10^5$$$) — the length of $$$a$$$, and the segment $$$[l,r]$$$.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\\ldots,a_n$$$ ($$$1 \\le a_{i} \\le 10^9$$$).\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_format": "For each test case, output the minimum value of $$$a_l+a_{l+1}+\\ldots+a_{r-1}+a_r$$$ on a separate line.", "interaction_format": null, "note": "On the second test case, the array is $$$a=[1,2,3]$$$ and the segment is $$$[2,3]$$$.\n\nAfter choosing the subsequence $$$a_1,a_3$$$ and reversing it, the sequence becomes $$$[3,2,1]$$$. Then, the sum $$$a_2+a_3$$$ becomes $$$3$$$. It can be shown that the minimum possible value of the sum is $$$3$$$.", "examples": [ { "input": "6\n2 1 1\n2 1\n3 2 3\n1 2 3\n3 1 3\n3 1 2\n4 2 3\n1 2 2 2\n5 2 5\n3 3 2 3 5\n6 1 3\n3 6 6 4 3 2", "output": "1\n3\n6\n3\n11\n8" } ], "editorial": "To solve this problem, it is important to observe and prove the following claim:\n• Claim: It is not beneficial to choose indices $$$ir$$$ at the same time.\nNotice that we only care about values that end up on indices in $$$[l,r]$$$.\nIf we choose $$$i_1,i_2,\\ldots,i_k$$$ such that $$$i_1r$$$, $$$i_1$$$ and $$$i_k$$$ will be swapped with each other and not change the values that end up on $$$[l,r]$$$. This means we can exchange it for a shorter sequence of indices $$$i_2,i_3,\\ldots,i_{k-1}$$$, preserving the values ending up on $$$[l,r]$$$. If we repeat this exchange until it is no longer possible, it will satisfy either:\n• Every index $$$i$$$ is in $$$[l,n]$$$;\n• or every index $$$i$$$ is in $$$[1,r]$$$.\nWe can solve for both cases separately. For either case, we can constructively show that we can get the minimum $$$r-l+1$$$ values in the subsegment into $$$[l,r]$$$. The proof is as follows:\nWLOG assume we are solving for $$$[1,r]$$$, and the indices of the $$$k=r-l+1$$$ minimum values are $$$j_1,j_2,\\ldots,j_k$$$. Then:\n• If we select every index in $$$[l,r]$$$ not one of the minimum $$$k$$$ values, there will be $$$x$$$ of them.\n• If we select every index outside $$$[l,r]$$$ which is one of the minimum $$$k$$$ values, there will be also $$$x$$$ of them.\nThus, we end up with a subsequence of length $$$2x$$$, that gets the minimum $$$k$$$ values into the subsegment $$$[l,r]$$$. As a result, we only have to find the minimum $$$k$$$ values of the subsegment. This can be done easily with sorting. Do this for both $$$[1,r]$$$ and $$$[l,n]$$$, and we get the answer.\nThe problem has been solved with time complexity $$$\\mathcal{O}(n \\log n)$$$ per test case, due to sorting.", "rating": 1100, "tags": [ "constructive algorithms", "data structures", "greedy", "sortings" ], "testset_size": 13, "official_tests": [ { "input": "6\r\n2 1 1\r\n2 1\r\n3 2 3\r\n1 2 3\r\n3 1 3\r\n3 1 2\r\n4 2 3\r\n1 2 2 2\r\n5 2 5\r\n3 3 2 3 5\r\n6 1 3\r\n3 6 6 4 3 2\r\n", "output": "1\r\n3\r\n6\r\n3\r\n11\r\n8\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2019/B", "aliases": null, "contest_id": "2019", "contest_name": "Codeforces Round 975 (Div. 2)", "contest_type": "CF", "contest_start": 1727444100, "contest_start_year": 2024, "index": "B", "time_limit": 1.5, "memory_limit": 256.0, "title": "All Pairs Segments", "description": "You are given $$$n$$$ points on the $$$x$$$ axis, at increasing positive integer coordinates $$$x_1 < x_2 < \\ldots < x_n$$$.\n\nFor each pair $$$(i, j)$$$ with $$$1 \\leq i < j \\leq n$$$, you draw the segment $$$[x_i, x_j]$$$. The segments are closed, i.e., a segment $$$[a, b]$$$ contains the points $$$a, a+1, \\ldots, b$$$.\n\nYou are given $$$q$$$ queries. In the $$$i$$$-th query, you are given a positive integer $$$k_i$$$, and you have to determine how many points with integer coordinates are contained in exactly $$$k_i$$$ segments.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $$$n$$$, $$$q$$$ ($$$2 \\le n \\le 10^5$$$, $$$1 \\le q \\le 10^5$$$) — the number of points and the number of queries.\n\nThe second line of each test case contains $$$n$$$ integers $$$x_1, x_2, \\ldots, x_n$$$ ($$$1 \\leq x_1 < x_2 < \\ldots < x_n \\leq 10^9$$$) — the coordinates of the $$$n$$$ points.\n\nThe third line of each test case contains $$$q$$$ integers $$$k_1, k_2, \\ldots, k_q$$$ ($$$1 \\leq k_i \\leq 10^{18}$$$) — the parameters of the $$$q$$$ queries.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$, and the sum of $$$q$$$ over all test cases does not exceed $$$10^5$$$.", "output_format": "For each test case, output a single line with $$$q$$$ integers: the $$$i$$$-th integer is the answer to the $$$i$$$-th query.", "interaction_format": null, "note": "In the first example, you only draw the segment $$$[101, 200]$$$. No point is contained in exactly $$$2$$$ segments, and the $$$100$$$ points $$$101, 102, \\ldots, 200$$$ are contained in exactly $$$1$$$ segment.\n\nIn the second example, you draw $$$15$$$ segments: $$$[1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [2, 3], [2, 5], [2, 6], [2, 7], [3, 5], [3, 6], [3, 7], [5, 6], [5, 7], [6, 7]$$$. Points $$$1, 7$$$ are contained in exactly $$$5$$$ segments; points $$$2, 4, 6$$$ are contained in exactly $$$9$$$ segments; points $$$3, 5$$$ are contained in exactly $$$11$$$ segments.", "examples": [ { "input": "3\n2 2\n101 200\n2 1\n6 15\n1 2 3 5 6 7\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n5 8\n254618033 265675151 461318786 557391198 848083778\n6 9 15 10 6 9 4 4294967300", "output": "0 100 \n0 0 0 0 2 0 0 0 3 0 2 0 0 0 0 \n291716045 0 0 0 291716045 0 301749698 0" } ], "editorial": null, "rating": 1200, "tags": [ "implementation", "math" ], "testset_size": 11, "official_tests": [ { "input": "3\r\n2 2\r\n101 200\r\n2 1\r\n6 15\r\n1 2 3 5 6 7\r\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\r\n5 8\r\n254618033 265675151 461318786 557391198 848083778\r\n6 9 15 10 6 9 4 4294967300\r\n", "output": "0 100 \r\n0 0 0 0 2 0 0 0 3 0 2 0 0 0 0 \r\n291716045 0 0 0 291716045 0 301749698 0 \r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2030/C", "aliases": null, "contest_id": "2030", "contest_name": "Codeforces Round 979 (Div. 2)", "contest_type": "CF", "contest_start": 1729346700, "contest_start_year": 2024, "index": "C", "time_limit": 2.0, "memory_limit": 256.0, "title": "A TRUE Battle", "description": "Alice and Bob are playing a game. There is a list of $$$n$$$ booleans, each of which is either true or false, given as a binary string $$$^{\\text{∗}}$$$ of length $$$n$$$ (where $$$\\texttt{1}$$$ represents true, and $$$\\texttt{0}$$$ represents false). Initially, there are no operators between the booleans.\n\nAlice and Bob will take alternate turns placing and or or between the booleans, with Alice going first. Thus, the game will consist of $$$n-1$$$ turns since there are $$$n$$$ booleans. Alice aims for the final statement to evaluate to true, while Bob aims for it to evaluate to false. Given the list of boolean values, determine whether Alice will win if both players play optimally.\n\nTo evaluate the final expression, repeatedly perform the following steps until the statement consists of a single true or false:\n\n- If the statement contains an and operator, choose any one and replace the subexpression surrounding it with its evaluation.\n- Otherwise, the statement contains an or operator. Choose any one and replace the subexpression surrounding the or with its evaluation.", "input_format": "The first line contains $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains an integer $$$n$$$ ($$$2 \\leq n \\leq 2 \\cdot 10^5$$$) — the length of the string.\n\nThe second line contains a binary string of length $$$n$$$, consisting of characters $$$\\texttt{0}$$$ and $$$\\texttt{1}$$$ — the list of boolean values.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each testcase, output \"YES\" (without quotes) if Alice wins, and \"NO\" (without quotes) otherwise.\n\nYou can output \"YES\" and \"NO\" in any case (for example, strings \"yES\", \"yes\" and \"Yes\" will be recognized as a positive response).", "interaction_format": null, "note": "In the first testcase, Alice can place and between the two booleans. The game ends as there are no other places to place operators, and Alice wins because true and true is true.\n\nIn the second testcase, Alice can place or between the middle true and the left false. Bob can place and between the middle true and the right false. The statement false or true and false is false.\n\nNote that these examples may not be the best strategies for either Alice or Bob.", "examples": [ { "input": "5\n2\n11\n3\n010\n12\n101111111100\n10\n0111111011\n8\n01000010", "output": "YES\nNO\nYES\nYES\nNO" } ], "editorial": null, "rating": 1100, "tags": [ "brute force", "games", "greedy" ], "testset_size": 11, "official_tests": [ { "input": "5\r\n2\r\n11\r\n3\r\n010\r\n12\r\n101111111100\r\n10\r\n0111111011\r\n8\r\n01000010\r\n", "output": "YES\r\nNO\r\nYES\r\nYES\r\nNO\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2056/C", "aliases": null, "contest_id": "2056", "contest_name": "Codeforces Round 997 (Div. 2)", "contest_type": "CF", "contest_start": 1737124500, "contest_start_year": 2025, "index": "C", "time_limit": 2.0, "memory_limit": 512.0, "title": "Palindromic Subsequences", "description": "For an integer sequence $$$a = [a_1, a_2, \\ldots, a_n]$$$, we define $$$f(a)$$$ as the length of the longest subsequence$$$^{\\text{∗}}$$$ of $$$a$$$ that is a palindrome$$$^{\\text{†}}$$$.\n\nLet $$$g(a)$$$ represent the number of subsequences of length $$$f(a)$$$ that are palindromes. In other words, $$$g(a)$$$ counts the number of palindromic subsequences in $$$a$$$ that have the maximum length.\n\nGiven an integer $$$n$$$, your task is to find any sequence $$$a$$$ of $$$n$$$ integers that satisfies the following conditions:\n\n- $$$1 \\le a_i \\le n$$$ for all $$$1 \\le i \\le n$$$.\n- $$$g(a) > n$$$\n\nIt can be proven that such a sequence always exists under the given constraints.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 100$$$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$\\color{red}{6} \\le n \\le 100$$$) — the length of the sequence.\n\nNote that there are no constraints on the sum of $$$n$$$ over all test cases.", "output_format": "For each test case, output $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$, representing an array that satisfies the conditions.\n\nIf there are multiple solutions, you may output any of them.", "interaction_format": null, "note": "In the first example, one possible solution is $$$a = [1, 1, 2, 3, 1, 2]$$$. In this case, $$$f(a) = 3$$$ as the longest palindromic subsequence has length $$$3$$$. There are $$$7$$$ ways to choose a subsequence of length $$$3$$$ that is a palindrome, as shown below:\n\n1. $$$[a_1, a_2, a_5] = [1, 1, 1]$$$\n2. $$$[a_1, a_3, a_5] = [1, 2, 1]$$$\n3. $$$[a_1, a_4, a_5] = [1, 3, 1]$$$\n4. $$$[a_2, a_3, a_5] = [1, 2, 1]$$$\n5. $$$[a_2, a_4, a_5] = [1, 3, 1]$$$\n6. $$$[a_3, a_4, a_6] = [2, 3, 2]$$$\n7. $$$[a_3, a_5, a_6] = [2, 1, 2]$$$\n\nTherefore, $$$g(a) = 7$$$, which is greater than $$$n = 6$$$. Hence, $$$a = [1, 1, 2, 3, 1, 2]$$$ is a valid solution.\n\nIn the second example, one possible solution is $$$a = [7, 3, 3, 7, 5, 3, 7, 7, 3]$$$. In this case, $$$f(a) = 5$$$. There are $$$24$$$ ways to choose a subsequence of length $$$5$$$ that is a palindrome. Some examples are $$$[a_2, a_4, a_5, a_8, a_9] = [3, 7, 5, 7, 3]$$$ and $$$[a_1, a_4, a_6, a_7, a_8] = [7, 7, 3, 7, 7]$$$. Therefore, $$$g(a) = 24$$$, which is greater than $$$n = 9$$$. Hence, $$$a = [7, 3, 3, 7, 5, 3, 7, 7, 3]$$$ is a valid solution.\n\nIn the third example, $$$f(a) = 7$$$ and $$$g(a) = 190$$$, which is greater than $$$n = 15$$$.", "examples": [ { "input": "3\n6\n9\n15", "output": "1 1 2 3 1 2\n7 3 3 7 5 3 7 7 3\n15 8 8 8 15 5 8 1 15 5 8 15 15 15 8" } ], "editorial": null, "rating": 1200, "tags": [ "brute force", "constructive algorithms", "math" ], "testset_size": 12, "official_tests": [ { "input": "3\r\n6\r\n9\r\n15\r\n", "output": "1 1 2 3 1 2\r\n7 3 3 7 5 3 7 7 3\r\n15 8 8 8 15 5 8 1 15 5 8 15 15 15 8\r\n" }, { "input": "95\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30\r\n31\r\n32\r\n33\r\n34\r\n35\r\n36\r\n37\r\n38\r\n39\r\n40\r\n41\r\n42\r\n43\r\n44\r\n45\r\n46\r\n47\r\n48\r\n49\r\n50\r\n51\r\n52\r\n53\r\n54\r\n55\r\n56\r\n57\r\n58\r\n59\r\n60\r\n61\r\n62\r\n63\r\n64\r\n65\r\n66\r\n67\r\n68\r\n69\r\n70\r\n71\r\n72\r\n73\r\n74\r\n75\r\n76\r\n77\r\n78\r\n79\r\n80\r\n81\r\n82\r\n83\r\n84\r\n85\r\n86\r\n87\r\n88\r\n89\r\n90\r\n91\r\n92\r\n93\r\n94\r\n95\r\n96\r\n97\r\n98\r\n99\r\n100\r\n", "output": "1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 1\n1 1 2 3 4 5 6 7 8 9 10 11 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1\n1 1 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 1\n1 1 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 1\n1 1 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 28 1\n1 1 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 28 29 1\n1 1 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 28 29 30 1\n1 1 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 28 29 30 31 1\n1 1 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 28 29 30 31 32 1\n1 1 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 28 29 30 31 32 33 1\n1 1 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 28 29 30 31 32 33 34 1\n1 1 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 28 29 30 31 32 33 34 35 1\n1 1 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 28 29 30 31 32 33 34 35 36 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n" }, { "input": "100\r\n63\r\n58\r\n76\r\n57\r\n74\r\n32\r\n11\r\n93\r\n98\r\n65\r\n29\r\n17\r\n19\r\n25\r\n55\r\n44\r\n65\r\n62\r\n98\r\n28\r\n66\r\n69\r\n97\r\n98\r\n64\r\n20\r\n66\r\n20\r\n66\r\n87\r\n27\r\n26\r\n53\r\n33\r\n68\r\n66\r\n86\r\n46\r\n86\r\n93\r\n47\r\n21\r\n79\r\n88\r\n97\r\n96\r\n90\r\n45\r\n16\r\n19\r\n96\r\n31\r\n95\r\n12\r\n25\r\n71\r\n14\r\n25\r\n8\r\n46\r\n59\r\n91\r\n24\r\n71\r\n82\r\n81\r\n94\r\n33\r\n66\r\n97\r\n26\r\n54\r\n33\r\n18\r\n38\r\n71\r\n92\r\n87\r\n67\r\n100\r\n20\r\n73\r\n11\r\n62\r\n19\r\n84\r\n66\r\n88\r\n56\r\n61\r\n68\r\n27\r\n76\r\n52\r\n42\r\n7\r\n49\r\n47\r\n74\r\n70\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 1\n1 1 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 28 29 30 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 1\n1 1 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 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1\n1 1 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 28 29 30 31 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 2 3 4 5 6 7 8 9 10 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1\n1 1 2 3 4 5 6 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 1\n1 1 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 28 29 30 31 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1\n1 1 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 28 29 30 31 32 33 34 35 36 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 1\n1 1 2 3 4 5 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 1\n" }, { "input": "100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n100\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n" }, { "input": "100\r\n78\r\n98\r\n81\r\n98\r\n92\r\n92\r\n95\r\n100\r\n81\r\n78\r\n94\r\n84\r\n97\r\n76\r\n91\r\n96\r\n97\r\n90\r\n98\r\n98\r\n70\r\n96\r\n100\r\n92\r\n100\r\n100\r\n100\r\n97\r\n95\r\n97\r\n98\r\n94\r\n89\r\n94\r\n99\r\n91\r\n100\r\n93\r\n92\r\n82\r\n90\r\n98\r\n93\r\n96\r\n84\r\n95\r\n98\r\n98\r\n90\r\n99\r\n100\r\n100\r\n81\r\n98\r\n98\r\n97\r\n94\r\n91\r\n88\r\n91\r\n95\r\n75\r\n99\r\n90\r\n98\r\n91\r\n98\r\n98\r\n100\r\n85\r\n90\r\n97\r\n80\r\n93\r\n98\r\n96\r\n93\r\n91\r\n94\r\n99\r\n97\r\n89\r\n99\r\n99\r\n81\r\n98\r\n75\r\n90\r\n62\r\n88\r\n97\r\n92\r\n100\r\n100\r\n86\r\n93\r\n94\r\n87\r\n95\r\n83\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 1\n" }, { "input": "10\r\n100\r\n100\r\n100\r\n99\r\n98\r\n100\r\n100\r\n99\r\n98\r\n99\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n" }, { "input": "1\r\n17\r\n", "output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2\r\n" }, { "input": "100\r\n98\r\n99\r\n100\r\n100\r\n100\r\n98\r\n99\r\n99\r\n95\r\n95\r\n100\r\n100\r\n100\r\n99\r\n100\r\n98\r\n96\r\n100\r\n99\r\n98\r\n100\r\n99\r\n100\r\n100\r\n100\r\n100\r\n98\r\n100\r\n100\r\n98\r\n99\r\n98\r\n100\r\n100\r\n99\r\n100\r\n99\r\n97\r\n99\r\n98\r\n100\r\n100\r\n98\r\n99\r\n99\r\n99\r\n100\r\n99\r\n96\r\n95\r\n97\r\n100\r\n99\r\n97\r\n97\r\n100\r\n99\r\n99\r\n93\r\n100\r\n97\r\n96\r\n100\r\n99\r\n97\r\n100\r\n97\r\n99\r\n100\r\n100\r\n95\r\n98\r\n99\r\n99\r\n94\r\n100\r\n95\r\n99\r\n95\r\n99\r\n97\r\n100\r\n99\r\n97\r\n100\r\n100\r\n100\r\n99\r\n99\r\n99\r\n97\r\n100\r\n99\r\n100\r\n97\r\n100\r\n100\r\n99\r\n100\r\n100\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n" }, { "input": "100\r\n6\r\n6\r\n12\r\n8\r\n7\r\n7\r\n6\r\n8\r\n6\r\n6\r\n6\r\n7\r\n14\r\n6\r\n7\r\n10\r\n7\r\n9\r\n8\r\n6\r\n6\r\n6\r\n11\r\n6\r\n6\r\n10\r\n6\r\n8\r\n7\r\n6\r\n6\r\n8\r\n6\r\n7\r\n9\r\n7\r\n6\r\n8\r\n7\r\n7\r\n6\r\n6\r\n7\r\n10\r\n8\r\n6\r\n6\r\n8\r\n6\r\n10\r\n8\r\n7\r\n8\r\n7\r\n7\r\n6\r\n7\r\n13\r\n6\r\n6\r\n7\r\n6\r\n7\r\n8\r\n6\r\n7\r\n11\r\n6\r\n6\r\n9\r\n6\r\n13\r\n6\r\n6\r\n7\r\n11\r\n9\r\n6\r\n11\r\n12\r\n8\r\n11\r\n9\r\n6\r\n6\r\n6\r\n6\r\n10\r\n6\r\n6\r\n10\r\n6\r\n7\r\n8\r\n6\r\n7\r\n8\r\n9\r\n7\r\n6\r\n", "output": "1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 10 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 9 10 11 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 10 11 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 1\n1 1 2 3 4 1\n" }, { "input": "10\r\n60\r\n30\r\n77\r\n53\r\n58\r\n63\r\n92\r\n91\r\n88\r\n99\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 1\n1 1 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 28 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n" }, { "input": "49\r\n50\r\n96\r\n100\r\n92\r\n65\r\n97\r\n77\r\n100\r\n74\r\n85\r\n97\r\n94\r\n91\r\n99\r\n70\r\n80\r\n94\r\n80\r\n59\r\n71\r\n95\r\n97\r\n66\r\n96\r\n90\r\n60\r\n52\r\n78\r\n98\r\n36\r\n82\r\n86\r\n100\r\n80\r\n86\r\n67\r\n62\r\n99\r\n77\r\n45\r\n59\r\n96\r\n96\r\n99\r\n96\r\n45\r\n64\r\n77\r\n92\r\n", "output": "1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 1\n1 1 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 28 29 30 31 32 33 34 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 1\n" }, { "input": "100\r\n16\r\n61\r\n21\r\n39\r\n6\r\n22\r\n21\r\n8\r\n9\r\n14\r\n24\r\n36\r\n17\r\n9\r\n16\r\n65\r\n9\r\n19\r\n58\r\n46\r\n11\r\n23\r\n7\r\n28\r\n9\r\n25\r\n29\r\n21\r\n19\r\n21\r\n17\r\n32\r\n38\r\n13\r\n9\r\n36\r\n13\r\n11\r\n19\r\n12\r\n11\r\n8\r\n39\r\n35\r\n11\r\n10\r\n17\r\n19\r\n32\r\n24\r\n30\r\n46\r\n18\r\n39\r\n6\r\n7\r\n20\r\n13\r\n14\r\n6\r\n11\r\n27\r\n22\r\n11\r\n8\r\n17\r\n32\r\n39\r\n17\r\n10\r\n56\r\n19\r\n31\r\n6\r\n16\r\n19\r\n24\r\n24\r\n17\r\n11\r\n14\r\n8\r\n18\r\n25\r\n37\r\n10\r\n10\r\n16\r\n17\r\n31\r\n11\r\n17\r\n6\r\n8\r\n50\r\n9\r\n31\r\n10\r\n8\r\n7\r\n", "output": "1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1\n1 1 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 28 29 30 31 32 33 34 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1\n1 1 2 3 4 5 1\n1 1 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 1\n1 1 2 3 4 5 6 7 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1\n1 1 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 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 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 28 29 30 1\n1 1 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 28 29 30 31 32 33 34 35 36 1\n1 1 2 3 4 5 6 7 8 9 10 11 1\n1 1 2 3 4 5 6 7 1\n1 1 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 28 29 30 31 32 33 34 1\n1 1 2 3 4 5 6 7 8 9 10 11 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 2 3 4 5 6 7 8 9 10 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 1\n1 1 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 28 29 30 31 32 33 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 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 28 29 30 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1\n1 1 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 28 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 1\n1 1 2 3 4 1\n1 1 2 3 4 5 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1\n1 1 2 3 4 5 6 7 8 9 10 11 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 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 28 29 30 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 5 6 7 8 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 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 28 29 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1\n1 1 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 28 29 30 31 32 33 34 35 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 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 28 29 1\n1 1 2 3 4 5 6 7 8 9 1\n1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1\n1 1 2 3 4 1\n1 1 2 3 4 5 6 1\n1 1 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 1\n1 1 2 3 4 5 6 7 1\n1 1 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 28 29 1\n1 1 2 3 4 5 6 7 8 1\n1 1 2 3 4 5 6 1\n1 1 2 3 4 5 1\n" } ], "official_tests_complete": true, "input_mode": "stdio", "generated_checker": "import sys\n\ndef readints(f):\n return list(map(int, f.readline().split()))\n\ndef compute_f_g(a):\n n = len(a)\n dp_len = [[0]*n for _ in range(n)]\n dp_count = [[0]*n for _ in range(n)]\n \n for i in range(n-1, -1, -1):\n for j in range(i, n):\n if i == j:\n dp_len[i][j] = 1\n dp_count[i][j] = 1\n else:\n if a[i] == a[j]:\n if i+1 <= j-1:\n temp_len = dp_len[i+1][j-1] + 2\n temp_count = dp_count[i+1][j-1]\n else:\n temp_len = 2\n temp_count = 1\n left_len = dp_len[i][j-1]\n right_len = dp_len[i+1][j]\n \n if temp_len > left_len and temp_len > right_len:\n current_len = temp_len\n current_count = temp_count\n else:\n if left_len > right_len:\n current_len = left_len\n current_count = dp_count[i][j-1]\n elif right_len > left_len:\n current_len = right_len\n current_count = dp_count[i+1][j]\n else:\n current_len = left_len\n current_count = dp_count[i][j-1] + dp_count[i+1][j]\n if i+1 <= j-1 and dp_len[i+1][j-1] == current_len:\n current_count -= dp_count[i+1][j-1]\n if temp_len > current_len:\n current_len = temp_len\n current_count = temp_count\n elif temp_len == current_len:\n current_count += temp_count\n dp_len[i][j] = current_len\n dp_count[i][j] = current_count\n else:\n left_len = dp_len[i][j-1]\n right_len = dp_len[i+1][j]\n if left_len > right_len:\n current_len = left_len\n current_count = dp_count[i][j-1]\n elif right_len > left_len:\n current_len = right_len\n current_count = dp_count[i+1][j]\n else:\n current_len = left_len\n current_count = dp_count[i][j-1] + dp_count[i+1][j]\n if i+1 <= j-1 and dp_len[i+1][j-1] == current_len:\n current_count -= dp_count[i+1][j-1]\n dp_len[i][j] = current_len\n dp_count[i][j] = current_count\n f_val = dp_len[0][n-1]\n g_val = dp_count[0][n-1]\n return f_val, g_val\n\ndef main(input_path, output_path, submission_output_path):\n with open(input_path) as f_in, open(submission_output_path) as f_sub:\n t = int(f_in.readline())\n for _ in range(t):\n n = int(f_in.readline().strip())\n a_line = f_sub.readline().strip()\n if not a_line:\n print(0)\n return\n a = list(map(int, a_line.split()))\n if len(a) != n:\n print(0)\n return\n for num in a:\n if not (1 <= num <= n):\n print(0)\n return\n f_val, g_val = compute_f_g(a)\n if g_val <= n:\n print(0)\n return\n print(1)\n\nif __name__ == \"__main__\":\n input_path = sys.argv[1]\n output_path = sys.argv[2]\n submission_output_path = sys.argv[3]\n main(input_path, output_path, submission_output_path)", "executable": true }, { "id": "2067/B", "aliases": null, "contest_id": "2067", "contest_name": "Codeforces Round 1004 (Div. 2)", "contest_type": "CF", "contest_start": 1739284500, "contest_start_year": 2025, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Two Large Bags", "description": "You have two large bags of numbers. Initially, the first bag contains $$$n$$$ numbers: $$$a_1, a_2, \\ldots, a_n$$$, while the second bag is empty. You are allowed to perform the following operations:\n\n- Choose any number from the first bag and move it to the second bag.\n- Choose a number from the first bag that is also present in the second bag and increase it by one.\n\nYou can perform an unlimited number of operations of both types, in any order. Is it possible to make the contents of the first and second bags identical?", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.\n\nThe first line of each test case contains an integer $$$n$$$ ($$$2 \\le n \\le 1000$$$) — the length of the array $$$a$$$. It is guaranteed that $$$n$$$ is an even number.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le n$$$).\n\nIt is guaranteed that the sum of $$$n^2$$$ over all test cases does not exceed $$$10^6$$$.", "output_format": "For each test case, print \"YES\" if it is possible to equalize the contents of the bags. Otherwise, output \"NO\".\n\nYou can output each letter in any case (for example, \"YES\", \"Yes\", \"yes\", \"yEs\", \"yEs\" will be recognized as a positive answer).", "interaction_format": null, "note": "Let's analyze the sixth test case: we will show the sequence of operations that leads to the equality of the bags. Initially, the first bag consists of the numbers $$$(3, 3, 4, 5, 3, 3)$$$, and the second bag is empty.\n\n1. In the first operation, move the number $$$3$$$ from the first bag to the second. State: $$$(3, 4, 5, 3, 3)$$$ and $$$(3)$$$.\n2. In the second operation, increase the number $$$3$$$ from the first bag by one. This operation is possible because the second bag contains the number $$$3$$$. State: $$$(4, 4, 5, 3, 3)$$$ and $$$(3)$$$.\n3. In the third operation, move the number $$$4$$$ from the first bag to the second. State: $$$(4, 5, 3, 3)$$$ and $$$(3, 4)$$$.\n4. In the fourth operation, increase the number $$$4$$$ from the first bag by one. State: $$$(5, 5, 3, 3)$$$ and $$$(3, 4)$$$.\n5. In the fifth operation, move the number $$$5$$$ from the first bag to the second. State: $$$(5, 3, 3)$$$ and $$$(3, 4, 5)$$$.\n6. In the sixth operation, increase the number $$$3$$$ from the first bag by one. State: $$$(5, 3, 4)$$$ and $$$(3, 4, 5)$$$.\n\nAs we can see, as a result of these operations, it is possible to make the contents of the bags equal, so the answer exists.", "examples": [ { "input": "9\n2\n1 1\n2\n2 1\n4\n1 1 4 4\n4\n3 4 3 3\n4\n2 3 4 4\n6\n3 3 4 5 3 3\n6\n2 2 2 4 4 4\n8\n1 1 1 1 1 1 1 4\n10\n9 9 9 10 10 10 10 10 10 10", "output": "Yes\nNo\nYes\nYes\nNo\nYes\nNo\nYes\nYes" } ], "editorial": "Note that when a number goes into the second bag, it remains unchanged there until the end of the entire process: our operations cannot interact with this number in any way.\nTherefore, every time we send a number to the second bag, we must keep in mind that an equal number must remain in the first bag by the end of the operations if we want to equalize the contents of the bags. We will call this equal number in the first bag \"blocked\": as no operations should be performed with it anymore.\nLet's sort the array: $$$a_1 \\leq a_2 \\leq \\ldots \\leq a_n$$$.\nThe first action we will take: sending one of the numbers to the second bag, since the second bag is empty at the beginning of the operations, which means the second operation is not available.\nWe will prove that at some point we will definitely want to send a number equal to $$$a_1$$$ to the second bag. Proof by contradiction. Suppose we never do this. Then all the numbers in the second bag, at the end of the operations, will be $$$>a_1$$$. And the number $$$a_1$$$ will remain in the first bag, which cannot be increased if we never sent $$$a_1$$$ to the second bag. Thus, the contents of the bags will never be equal if we do not send the number $$$a_1$$$ to the second bag. Therefore, during the operations, we must do this. And we can do this as the first operation since operations with numbers $$$>a_1$$$ do not interact with $$$a_1$$$ in any case.\nAlright, our first move: transfer $$$a_1$$$ to the second bag. Now we need to \"block\" one copy of the number $$$a_1$$$ in the first bag and not use it in further operations. Therefore, if $$$a_2 > a_1$$$, we instantly lose. Otherwise, we fix $$$a_2=a_1$$$ in the first bag and $$$a_1$$$ in the second bag.\nAnd we return to the original problem, but now with the numbers $$$a_3, a_4, \\ldots, a_n$$$. However, now we have the number $$$=a_1$$$ in the second bag. This means that now, perhaps, the first action should not be to transfer the minimum to the second bag, but to somehow use the second operation.\nIt turns out that it is always optimal to use the second operation when possible, not counting the \"blocked\" numbers. That is, to increase all equal $$$a_1$$$ numbers in the first bag by one. And then proceed to the same problem, but with a reduced $$$n$$$.\nWhy is this so? Suppose we leave some equal $$$a_1$$$ numbers in the first bag without increasing them. Then, by the same logic, we must transfer one of them to the second bag, blocking the equal number in the first bag. But the same could be done if we increased both numbers by $$$1$$$, they would still be equal, and there would still be the option to transfer one of them to the second bag and block the equal one in the first. Moreover, the number equal to $$$a_1$$$ is already in the second bag, so adding a second copy does not expand the arsenal of possible operations in any way. Therefore, it is never worse to add one to all remaining $$$=a_1$$$ numbers. And proceed to the problem with the array $$$a_3,a_4,\\ldots,a_n$$$, where all numbers are $$$>a_1$$$, which can already be solved similarly.\nA naive simulation of this process takes $$$O(n^2)$$$, but, of course, it can be handled in $$$O(n \\log n)$$$ without much effort, and if we sort the array using counting sort, it can be done in $$$O(n)$$$ altogether.", "rating": 1200, "tags": [ "brute force", "dp", "greedy", "sortings" ], "testset_size": 10, "official_tests": [ { "input": "9\r\n2\r\n1 1\r\n2\r\n2 1\r\n4\r\n1 1 4 4\r\n4\r\n3 4 3 3\r\n4\r\n2 3 4 4\r\n6\r\n3 3 4 5 3 3\r\n6\r\n2 2 2 4 4 4\r\n8\r\n1 1 1 1 1 1 1 4\r\n10\r\n9 9 9 10 10 10 10 10 10 10\r\n", "output": "Yes\r\nNo\r\nYes\r\nYes\r\nNo\r\nYes\r\nNo\r\nYes\r\nYes\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2005/B2", "aliases": null, "contest_id": "2005", "contest_name": "Codeforces Round 972 (Div. 2)", "contest_type": "CF", "contest_start": 1726324500, "contest_start_year": 2024, "index": "B2", "time_limit": 1.5, "memory_limit": 256.0, "title": "The Strict Teacher (Hard Version)", "description": "This is the hard version of the problem. The only differences between the two versions are the constraints on $$$m$$$ and $$$q$$$. In this version, $$$m, q \\le 10^5$$$. You can make hacks only if both versions of the problem are solved.\n\nNarek and Tsovak were busy preparing this round, so they have not managed to do their homework and decided to steal David's homework. Their strict teacher noticed that David has no homework and now wants to punish him. She hires other teachers to help her catch David. And now $$$m$$$ teachers together are chasing him. Luckily, the classroom is big, so David has many places to hide.\n\nThe classroom can be represented as a one-dimensional line with cells from $$$1$$$ to $$$n$$$, inclusive.\n\nAt the start, all $$$m$$$ teachers and David are in distinct cells. Then they make moves. During each move\n\n- David goes to an adjacent cell or stays at the current one.\n- Then, each of the $$$m$$$ teachers simultaneously goes to an adjacent cell or stays at the current one.\n\nThis continues until David is caught. David is caught if any of the teachers (possibly more than one) is located in the same cell as David. Everyone sees others' moves, so they all act optimally.\n\nYour task is to find how many moves it will take for the teachers to catch David if they all act optimally.\n\nActing optimally means the student makes his moves in a way that maximizes the number of moves the teachers need to catch him; and the teachers coordinate with each other to make their moves in a way that minimizes the number of moves they need to catch the student.\n\nAlso, as Narek and Tsovak think this task is easy, they decided to give you $$$q$$$ queries on David's position.", "input_format": "In the first line of the input, you are given a single integer $$$t$$$ ($$$1 \\le t \\le 10^5$$$) — the number of test cases. The description of each test case follows.\n\nIn the first line of each test case, you are given three integers $$$n$$$, $$$m$$$, and $$$q$$$ ($$$3 \\le n \\le 10^9$$$, $$$1 \\le m, q \\le 10^5$$$) — the number of cells on the line, the number of teachers, and the number of queries.\n\nIn the second line of each test case, you are given $$$m$$$ distinct integers $$$b_1, b_2, \\ldots, b_m$$$ ($$$1 \\le b_i \\le n$$$) — the cell numbers of the teachers.\n\nIn the third line of each test case, you are given $$$q$$$ integers $$$a_1, a_2, \\ldots, a_q$$$ ($$$1 \\le a_i \\le n$$$) — David's cell number for every query.\n\nIt is guaranteed that for any $$$i$$$, $$$j$$$ such that $$$1 \\le i \\le m$$$ and $$$1 \\le j \\le q$$$, $$$b_i \\neq a_j$$$.\n\nIt is guaranteed that the sum of values of $$$m$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.\n\nIt is guaranteed that the sum of values of $$$q$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output $$$q$$$ lines, the $$$i$$$-th of them containing the answer of the $$$i$$$-th query.", "interaction_format": null, "note": "In the only query of the first example, the student can run to cell $$$1$$$. It will take the teacher five moves to reach from cell $$$6$$$ to cell $$$1$$$, so the answer is $$$5$$$.\n\nIn the second query of the second example, the student can just stay at cell $$$3$$$. The teacher, initially located in cell $$$4$$$, can reach cell $$$3$$$ in one move. Therefore, the answer is $$$1$$$.", "examples": [ { "input": "2\n8 1 1\n6\n3\n10 3 3\n1 4 8\n2 3 10", "output": "5\n1\n1\n2" } ], "editorial": null, "rating": 1200, "tags": [ "binary search", "greedy", "math", "sortings" ], "testset_size": 12, "official_tests": [ { "input": "2\r\n8 1 1\r\n6\r\n3\r\n10 3 3\r\n1 4 8\r\n2 3 10\r\n", "output": "5\r\n1\r\n1\r\n2\r\n" }, { "input": "1\r\n3 1 1\r\n2\r\n1\r\n", "output": "1\r\n" }, { "input": "1\r\n100 5 2\r\n20 30 40 50 52\r\n51 22\r\n", "output": "1\r\n5\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2009/C", "aliases": null, "contest_id": "2009", "contest_name": "Codeforces Round 971 (Div. 4)", "contest_type": "ICPC", "contest_start": 1725374100, "contest_start_year": 2024, "index": "C", "time_limit": 2.0, "memory_limit": 256.0, "title": "The Legend of Freya the Frog", "description": "Freya the Frog is traveling on the 2D coordinate plane. She is currently at point $$$(0,0)$$$ and wants to go to point $$$(x,y)$$$. In one move, she chooses an integer $$$d$$$ such that $$$0 \\leq d \\leq k$$$ and jumps $$$d$$$ spots forward in the direction she is facing.\n\nInitially, she is facing the positive $$$x$$$ direction. After every move, she will alternate between facing the positive $$$x$$$ direction and the positive $$$y$$$ direction (i.e., she will face the positive $$$y$$$ direction on her second move, the positive $$$x$$$ direction on her third move, and so on).\n\nWhat is the minimum amount of moves she must perform to land on point $$$(x,y)$$$?", "input_format": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases.\n\nEach test case contains three integers $$$x$$$, $$$y$$$, and $$$k$$$ ($$$0 \\leq x, y \\leq 10^9, 1 \\leq k \\leq 10^9$$$).", "output_format": "For each test case, output the number of jumps Freya needs to make on a new line.", "interaction_format": null, "note": "In the first sample, one optimal set of moves is if Freya jumps in the following way: ($$$0,0$$$) $$$\\rightarrow$$$ ($$$2,0$$$) $$$\\rightarrow$$$ ($$$2,2$$$) $$$\\rightarrow$$$ ($$$3,2$$$) $$$\\rightarrow$$$ ($$$3,5$$$) $$$\\rightarrow$$$ ($$$6,5$$$) $$$\\rightarrow$$$ ($$$6,8$$$) $$$\\rightarrow$$$ ($$$9,8$$$) $$$\\rightarrow$$$ ($$$9,11$$$). This takes 8 jumps.", "examples": [ { "input": "3\n9 11 3\n0 10 8\n1000000 100000 10", "output": "8\n4\n199999" } ], "editorial": null, "rating": 1100, "tags": [ "implementation", "math" ], "testset_size": 5, "official_tests": [ { "input": "3\r\n9 11 3\r\n0 10 8\r\n1000000 100000 10\r\n", "output": "8\r\n4\r\n199999\r\n" }, { "input": "1\r\n1 1000000000 1\r\n", "output": "2000000000\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2020/B", "aliases": null, "contest_id": "2020", "contest_name": "Codeforces Round 976 (Div. 2) and Divide By Zero 9.0", "contest_type": "CF", "contest_start": 1727624100, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Brightness Begins", "description": "Imagine you have $$$n$$$ light bulbs numbered $$$1, 2, \\ldots, n$$$. Initially, all bulbs are on. To flip the state of a bulb means to turn it off if it used to be on, and to turn it on otherwise.\n\nNext, you do the following:\n\n- for each $$$i = 1, 2, \\ldots, n$$$, flip the state of all bulbs $$$j$$$ such that $$$j$$$ is divisible by $$$i^\\dagger$$$.\n\nAfter performing all operations, there will be several bulbs that are still on. Your goal is to make this number exactly $$$k$$$.\n\nFind the smallest suitable $$$n$$$ such that after performing the operations there will be exactly $$$k$$$ bulbs on. We can show that an answer always exists.\n\n$$$^\\dagger$$$ An integer $$$x$$$ is divisible by $$$y$$$ if there exists an integer $$$z$$$ such that $$$x = y\\cdot z$$$.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.\n\nThe only line of each test case contains a single integer $$$k$$$ ($$$1 \\le k \\le 10^{18}$$$).", "output_format": "For each test case, output $$$n$$$ — the minimum number of bulbs.", "interaction_format": null, "note": "In the first test case, the minimum number of bulbs is $$$2$$$. Let's denote the state of all bulbs with an array, where $$$1$$$ corresponds to a turned on bulb, and $$$0$$$ corresponds to a turned off bulb. Initially, the array is $$$[1, 1]$$$.\n\n- After performing the operation with $$$i = 1$$$, the array becomes $$$[\\underline{0}, \\underline{0}]$$$.\n- After performing the operation with $$$i = 2$$$, the array becomes $$$[0, \\underline{1}]$$$.\n\nIn the end, there are $$$k = 1$$$ bulbs on. We can also show that the answer cannot be less than $$$2$$$.\n\nIn the second test case, the minimum number of bulbs is $$$5$$$. Initially, the array is $$$[1, 1, 1, 1, 1]$$$.\n\n- After performing the operation with $$$i = 1$$$, the array becomes $$$[\\underline{0}, \\underline{0}, \\underline{0}, \\underline{0}, \\underline{0}]$$$.\n- After performing the operation with $$$i = 2$$$, the array becomes $$$[0, \\underline{1}, 0, \\underline{1}, 0]$$$.\n- After performing the operation with $$$i = 3$$$, the array becomes $$$[0, 1, \\underline{1}, 1, 0]$$$.\n- After performing the operation with $$$i = 4$$$, the array becomes $$$[0, 1, 1, \\underline{0}, 0]$$$.\n- After performing the operation with $$$i = 5$$$, the array becomes $$$[0, 1, 1, 0, \\underline{1}]$$$.\n\nIn the end, there are $$$k = 3$$$ bulbs on. We can also show that the answer cannot be smaller than $$$5$$$.", "examples": [ { "input": "3\n1\n3\n8", "output": "2\n5\n11" } ], "editorial": "For any bulb $$$i$$$, its final state depends on the parity of the number of divisors of $$$i$$$. If $$$i$$$ has an even number of divisors, then bulb $$$i$$$ will be on; else it will be off. This translates to, if $$$i$$$ is not a perfect square, bulb $$$i$$$ will be on; else it will be off. So now the problem is to find the $$$k$$$th number which is not a perfect square. This can be done by binary searching the value of $$$n$$$ such that $$$n- \\lfloor \\sqrt{n} \\rfloor = k$$$ or the direct formula $$$n$$$ = $$$\\lfloor k + \\sqrt{k} + 0.5 \\rfloor$$$.", "rating": 1200, "tags": [ "binary search", "math" ], "testset_size": 10, "official_tests": [ { "input": "3\r\n1\r\n3\r\n8\r\n", "output": "2\r\n5\r\n11\r\n" }, { "input": "1\r\n1000000000000000000\r\n", "output": "1000000001000000000\r\n" }, { "input": "100\r\n39\r\n77\r\n47\r\n31\r\n86\r\n25\r\n72\r\n54\r\n65\r\n53\r\n65\r\n75\r\n87\r\n43\r\n42\r\n61\r\n75\r\n21\r\n48\r\n9\r\n40\r\n13\r\n48\r\n17\r\n80\r\n7\r\n89\r\n74\r\n94\r\n7\r\n6\r\n58\r\n13\r\n84\r\n17\r\n43\r\n62\r\n86\r\n48\r\n22\r\n46\r\n48\r\n100\r\n97\r\n1\r\n42\r\n94\r\n41\r\n8\r\n73\r\n60\r\n44\r\n69\r\n38\r\n66\r\n16\r\n1\r\n47\r\n2\r\n50\r\n57\r\n58\r\n30\r\n33\r\n29\r\n68\r\n71\r\n92\r\n70\r\n15\r\n80\r\n36\r\n34\r\n32\r\n35\r\n23\r\n59\r\n31\r\n84\r\n50\r\n20\r\n66\r\n20\r\n60\r\n80\r\n21\r\n31\r\n8\r\n93\r\n96\r\n82\r\n80\r\n34\r\n39\r\n26\r\n100\r\n33\r\n30\r\n52\r\n35\r\n", "output": "45\r\n86\r\n54\r\n37\r\n95\r\n30\r\n80\r\n61\r\n73\r\n60\r\n73\r\n84\r\n96\r\n50\r\n48\r\n69\r\n84\r\n26\r\n55\r\n12\r\n46\r\n17\r\n55\r\n21\r\n89\r\n10\r\n98\r\n83\r\n104\r\n10\r\n8\r\n66\r\n17\r\n93\r\n21\r\n50\r\n70\r\n95\r\n55\r\n27\r\n53\r\n55\r\n110\r\n107\r\n2\r\n48\r\n104\r\n47\r\n11\r\n82\r\n68\r\n51\r\n77\r\n44\r\n74\r\n20\r\n2\r\n54\r\n3\r\n57\r\n65\r\n66\r\n35\r\n39\r\n34\r\n76\r\n79\r\n102\r\n78\r\n19\r\n89\r\n42\r\n40\r\n38\r\n41\r\n28\r\n67\r\n37\r\n93\r\n57\r\n24\r\n74\r\n24\r\n68\r\n89\r\n26\r\n37\r\n11\r\n103\r\n106\r\n91\r\n89\r\n40\r\n45\r\n31\r\n110\r\n39\r\n35\r\n59\r\n41\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2046/A", "aliases": [ "2047/C" ], "contest_id": "2046", "contest_name": "Codeforces Round 990 (Div. 1)", "contest_type": "CF", "contest_start": 1733207100, "contest_start_year": 2024, "index": "A", "time_limit": 2.0, "memory_limit": 512.0, "title": "Swap Columns and Find a Path", "description": "There is a matrix consisting of $$$2$$$ rows and $$$n$$$ columns. The rows are numbered from $$$1$$$ to $$$2$$$ from top to bottom; the columns are numbered from $$$1$$$ to $$$n$$$ from left to right. Let's denote the cell on the intersection of the $$$i$$$-th row and the $$$j$$$-th column as $$$(i,j)$$$. Each cell contains an integer; initially, the integer in the cell $$$(i,j)$$$ is $$$a_{i,j}$$$.\n\nYou can perform the following operation any number of times (possibly zero):\n\n- choose two columns and swap them (i. e. choose two integers $$$x$$$ and $$$y$$$ such that $$$1 \\le x < y \\le n$$$, then swap $$$a_{1,x}$$$ with $$$a_{1,y}$$$, and then swap $$$a_{2,x}$$$ with $$$a_{2,y}$$$).\n\nAfter performing the operations, you have to choose a path from the cell $$$(1,1)$$$ to the cell $$$(2,n)$$$. For every cell $$$(i,j)$$$ in the path except for the last, the next cell should be either $$$(i+1,j)$$$ or $$$(i,j+1)$$$. Obviously, the path cannot go outside the matrix.\n\nThe cost of the path is the sum of all integers in all $$$(n+1)$$$ cells belonging to the path. You have to perform the operations and choose a path so that its cost is maximum possible.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 5000$$$). The description of the test cases follows.\n\nEach test case consists of three lines:\n\n- the first line contains one integer $$$n$$$ ($$$1 \\le n \\le 5000$$$) — the number of columns in the matrix;\n- the second line contains $$$n$$$ integers $$$a_{1,1}, a_{1,2}, \\ldots, a_{1,n}$$$ ($$$-10^5 \\le a_{i,j} \\le 10^5$$$) — the first row of the matrix;\n- the third line contains $$$n$$$ integers $$$a_{2,1}, a_{2,2}, \\ldots, a_{2,n}$$$ ($$$-10^5 \\le a_{i,j} \\le 10^5$$$) — the second row of the matrix.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$.", "output_format": "For each test case, print one integer — the maximum cost of a path you can obtain.", "interaction_format": null, "note": "Here are the explanations of the first three test cases of the example. The left matrix is the matrix given in the input, the right one is the state of the matrix after several column swaps (possibly zero). The optimal path is highlighted in green.", "examples": [ { "input": "3\n1\n-10\n5\n3\n1 2 3\n10 -5 -3\n4\n2 8 5 3\n1 10 3 4", "output": "-5\n16\n29" } ], "editorial": "We can divide the columns in the matrix into three different groups:\n1. the columns where we go through the top cell;\n2. the columns where we go through the bottom cell;\n3. the columns where we go through both cells.\nThere should be exactly one column in the $$$3$$$-rd group — this will be the column where we shift from the top row to the bottom row. However, all other columns can be redistributed between groups $$$1$$$ and $$$2$$$ as we want: if we want to put a column into the $$$1$$$-st group, we put it before the column where we go down; otherwise, we put it after the column where we go down. So, we can get any distribution of columns between the $$$1$$$-st and the $$$2$$$-nd group.\nNow let's consider the contribution of each column to the answer. Columns from the $$$1$$$-st group add $$$a_{1,i}$$$ to the answer, columns from the $$$2$$$-nd group add $$$a_{2,i}$$$, the column from the $$$3$$$-rd group adds both of these values. So, we can iterate on the index of the column where we go down, take $$$a_{1,i} + a_{2,i}$$$ for it, and take $$$\\max(a_{1,j}, a_{2,j})$$$ for every other column. This works in $$$O(n^2)$$$, and under the constraints of the problem, it is enough.\nHowever, it is possible to solve the problem in $$$O(n)$$$. To do so, calculate the sum of $$$\\max(a_{1,j}, a_{2,j})$$$ over all columns. Then, if we pick the $$$i$$$-th column as the column where we go down, the answer be equal to this sum, plus $$$\\min(a_{1,i}, a_{2,i})$$$, since this will be the only column where we visit both cells.", "rating": 1200, "tags": [ "greedy", "sortings" ], "testset_size": 15, "official_tests": [ { "input": "3\r\n1\r\n-10\r\n5\r\n3\r\n1 2 3\r\n10 -5 -3\r\n4\r\n2 8 5 3\r\n1 10 3 4\r\n", "output": "-5\r\n16\r\n29\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2024/B", "aliases": null, "contest_id": "2024", "contest_name": "Codeforces Round 980 (Div. 2)", "contest_type": "CF", "contest_start": 1729415100, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Buying Lemonade", "description": "There is a vending machine that sells lemonade. The machine has a total of $$$n$$$ slots. You know that initially, the $$$i$$$-th slot contains $$$a_i$$$ cans of lemonade. There are also $$$n$$$ buttons on the machine, each button corresponds to a slot, with exactly one button corresponding to each slot. Unfortunately, the labels on the buttons have worn off, so you do not know which button corresponds to which slot.\n\nWhen you press the button corresponding to the $$$i$$$-th slot, one of two events occurs:\n\n- If there is a can of lemonade in the $$$i$$$-th slot, it will drop out and you will take it. At this point, the number of cans in the $$$i$$$-th slot decreases by $$$1$$$.\n- If there are no cans of lemonade left in the $$$i$$$-th slot, nothing will drop out.\n\nAfter pressing, the can drops out so quickly that it is impossible to track from which slot it fell. The contents of the slots are hidden from your view, so you cannot see how many cans are left in each slot. The only thing you know is the initial number of cans in the slots: $$$a_1, a_2, \\ldots, a_n$$$.\n\nDetermine the minimum number of button presses needed to guarantee that you receive at least $$$k$$$ cans of lemonade.\n\nNote that you can adapt your strategy during the button presses based on whether you received a can or not. It is guaranteed that there are at least $$$k$$$ cans of lemonade in total in the machine. In other words, $$$k \\leq a_1 + a_2 + \\ldots + a_n$$$.", "input_format": "Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$, $$$1 \\leq k \\leq 10^9$$$) — the number of slots in the machine and the required number of cans of lemonade.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) — the number of cans in the slots.\n\nIt is guaranteed that $$$k \\leq a_1 + a_2 + \\ldots + a_n$$$, meaning there are at least $$$k$$$ cans of lemonade in the machine.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output a single integer — the minimum number of button presses needed to guarantee that you receive at least $$$k$$$ cans of lemonade.", "interaction_format": null, "note": "In the first test case, we can simply press the first button and receive one can of lemonade.\n\nIn the second test case, we can press each button once and guarantee that we receive $$$2$$$ cans of lemonade. Note that if we simply press one button twice, we might not be lucky, and that button could correspond to the first slot, in which case we would only receive $$$1$$$ can of lemonade for two presses.\n\nIn the third test case, one of the optimal strategies is as follows:\n\nPress the first button twice. After the first press, a can of lemonade will definitely drop out. Then there are two options:\n\n- If no can of lemonade drops after the second press, we know that this button must correspond to the second slot, since $$$a_2 = 1$$$ and $$$a_1, a_3 > 1$$$. Then we can press the second button twice and the third button once. Since $$$a_1, a_3 \\geq 2$$$, we will definitely receive three cans of lemonade for these three presses. Thus, after $$$5$$$ presses, we will have $$$4$$$ cans of lemonade.\n- If a can of lemonade drops after the second press, we can make one press on the second button and one press on the third button. After each of these presses, we will definitely receive a can of lemonade. Thus, after $$$4$$$ presses, we will have $$$4$$$ cans of lemonade.\n\nIt can be shown that it is impossible to guarantee receiving $$$4$$$ cans of lemonade with only $$$4$$$ presses, so the answer is $$$5$$$.", "examples": [ { "input": "5\n2 1\n1 1\n2 2\n1 2\n3 4\n2 1 3\n10 50\n1 1 3 8 8 9 12 13 27 27\n2 1000000000\n1000000000 500000000", "output": "1\n2\n5\n53\n1000000000" } ], "editorial": "Let's make a few simple observations about the optimal strategy of actions. First, if after pressing a certain button, no cans have been obtained, there is no point in pressing that button again. Second, among the buttons that have not yet resulted in a failure, it is always advantageous to press the button that has been pressed the least number of times. This can be loosely justified by the fact that the fewer times a button has been pressed, the greater the chance that the next press will be successful, as we have no other information to distinguish these buttons from one another. From this, our strategy clearly emerges: let's sort the array, let $$$a_1 \\leq a_2 \\leq \\ldots a_n$$$. In the first action, we will press all buttons $$$a_1$$$ times. It is clear that all these presses will yield cans, and in total, we will collect $$$a_1 \\cdot n$$$ cans. If $$$k \\leq a_1 \\cdot n$$$, no further presses are needed. However, if $$$k > a_1 \\cdot n$$$, we need to make at least one more press. Since all buttons are still indistinguishable to us, it may happen that this press will be made on the button corresponding to $$$a_1$$$ and will be unsuccessful. Next, we will press all remaining buttons $$$a_2 - a_1$$$ times; these presses will also be guaranteed to be successful. After that, again, if $$$k$$$ does not exceed the number of cans already collected, we finish; otherwise, we need to make at least one more press, which may hit an empty cell $$$a_2$$$. And so on. In total, the answer to the problem will be $$$k + x$$$, where $$$x$$$ is the smallest number from $$$0$$$ to $$$n-1$$$ such that the following holds: $$$\\displaystyle\\sum_{i=0}^{x} (a_{i+1}-a_i) \\cdot (n-i) \\geq k$$$ (here we consider $$$a_0 = 0$$$). $$$O(n \\log n)$$$.", "rating": 1100, "tags": [ "binary search", "constructive algorithms", "sortings" ], "testset_size": 21, "official_tests": [ { "input": "5\r\n2 1\r\n1 1\r\n2 2\r\n1 2\r\n3 4\r\n2 1 3\r\n10 50\r\n1 1 3 8 8 9 12 13 27 27\r\n2 1000000000\r\n1000000000 500000000\r\n", "output": "1\r\n2\r\n5\r\n53\r\n1000000000\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2039/C1", "aliases": null, "contest_id": "2039", "contest_name": "CodeTON Round 9 (Div. 1 + Div. 2, Rated, Prizes!)", "contest_type": "CF", "contest_start": 1732372500, "contest_start_year": 2024, "index": "C1", "time_limit": 2.0, "memory_limit": 256.0, "title": "Shohag Loves XOR (Easy Version)", "description": "This is the easy version of the problem. The differences between the two versions are highlighted in bold. You can only make hacks if both versions of the problem are solved.\n\nShohag has two integers $$$x$$$ and $$$m$$$. Help him count the number of integers $$$1 \\le y \\le m$$$ such that $$$\\mathbf{x \\neq y}$$$ and $$$x \\oplus y$$$ is a divisor$$$^{\\text{∗}}$$$ of either $$$x$$$, $$$y$$$, or both. Here $$$\\oplus$$$ is the bitwise XOR operator.", "input_format": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases.\n\nThe first and only line of each test case contains two space-separated integers $$$x$$$ and $$$m$$$ ($$$1 \\le x \\le 10^6$$$, $$$1 \\le m \\le 10^{18}$$$).\n\nIt is guaranteed that the sum of $$$x$$$ over all test cases does not exceed $$$10^7$$$.", "output_format": "For each test case, print a single integer — the number of suitable $$$y$$$.", "interaction_format": null, "note": "In the first test case, for $$$x = 6$$$, there are $$$3$$$ valid values for $$$y$$$ among the integers from $$$1$$$ to $$$m = 9$$$, and they are $$$4$$$, $$$5$$$, and $$$7$$$.\n\n- $$$y = 4$$$ is valid because $$$x \\oplus y = 6 \\oplus 4 = 2$$$ and $$$2$$$ is a divisor of both $$$x = 6$$$ and $$$y = 4$$$.\n- $$$y = 5$$$ is valid because $$$x \\oplus y = 6 \\oplus 5 = 3$$$ and $$$3$$$ is a divisor of $$$x = 6$$$.\n- $$$y = 7$$$ is valid because $$$x \\oplus y = 6 \\oplus 7 = 1$$$ and $$$1$$$ is a divisor of both $$$x = 6$$$ and $$$y = 7$$$.\n\nIn the second test case, for $$$x = 5$$$, there are $$$2$$$ valid values for $$$y$$$ among the integers from $$$1$$$ to $$$m = 7$$$, and they are $$$4$$$ and $$$6$$$.\n\n- $$$y = 4$$$ is valid because $$$x \\oplus y = 5 \\oplus 4 = 1$$$ and $$$1$$$ is a divisor of both $$$x = 5$$$ and $$$y = 4$$$.\n- $$$y = 6$$$ is valid because $$$x \\oplus y = 5 \\oplus 6 = 3$$$ and $$$3$$$ is a divisor of $$$y = 6$$$.", "examples": [ { "input": "5\n6 9\n5 7\n2 3\n6 4\n4 1", "output": "3\n2\n1\n1\n0" } ], "editorial": "THOUGHT: Here $$$x > 0$$$ and $$$y > 0$$$. So $$$x \\oplus y$$$ is neither equal to $$$x$$$ nor $$$y$$$. So $$$x \\oplus y$$$ is a divisor of $$$x$$$ or $$$y$$$ and $$$x \\oplus y < x$$$ or $$$x \\oplus y < y$$$.\nOBSERVATION: Any divisor $$$d$$$ of $$$p$$$ such that $$$d < p$$$ we know that $$$d \\le \\lfloor \\frac{p}{2} \\rfloor$$$.\nAlso, the highest bits of $$$d$$$ and $$$p$$$ are different when $$$d \\le \\lfloor \\frac{p}{2} \\rfloor$$$.\nTHOUGHT: Wait but $$$x \\oplus y$$$ has the same highest bit as $$$y$$$ if $$$y \\ge 2 \\cdot x$$$.\nCONCLUSION: So if $$$y \\ge 2 \\cdot x$$$, then $$$x \\oplus y$$$ can not be a divisor of $$$y$$$.\nTHOUGHT: But can it be a divisor of $$$x$$$?\nOBSERVATION: If $$$y \\ge 2 \\cdot x$$$, then $$$x \\oplus y > x$$$ because the highest bit in $$$x \\oplus y$$$ is greater than that in $$$x$$$. So $$$x \\oplus y$$$ can not be a divisor of $$$x$$$.\nCONCLUSION: If $$$y \\ge 2 \\cdot x$$$, then $$$x \\oplus y$$$ can not be a divisor of $$$x$$$ or $$$y$$$. So no solution in this case.\nTHOUGHT: Now we need to consider the case when $$$y < 2 \\cdot x$$$. But $$$x$$$ is small in this problem, making it feasible to iterate over all possible values of $$$y$$$.\nACTION: Iterate over all possible values of $$$y < 2 \\cdot x$$$ and check if $$$x \\oplus y$$$ is a divisor of either $$$x$$$ or $$$y$$$.\nTime Complexity: $$$\\mathcal{O}(x)$$$.", "rating": 1200, "tags": [ "bitmasks", "brute force", "math", "number theory" ], "testset_size": 22, "official_tests": [ { "input": "5\r\n6 9\r\n5 7\r\n2 3\r\n6 4\r\n4 1\r\n", "output": "3\r\n2\r\n1\r\n1\r\n0\r\n" }, { "input": "10\r\n999991 1000000000000000000\r\n999992 1000000000000000000\r\n999993 1000000000000000000\r\n999994 1000000000000000000\r\n999995 1000000000000000000\r\n999996 1000000000000000000\r\n999997 1000000000000000000\r\n999998 1000000000000000000\r\n999999 1000000000000000000\r\n1000000 1000000000000000000\r\n", "output": "13\r\n36\r\n12\r\n20\r\n5\r\n36\r\n11\r\n17\r\n69\r\n67\r\n" }, { "input": "11\r\n997920 1000000000000000000\r\n999600 1000000000000000000\r\n499800 1000000000000000000\r\n498960 1000000000000000000\r\n196560 1000000000000000000\r\n974400 1000000000000000000\r\n907200 1000000000000000000\r\n514080 1000000000000000000\r\n900900 1000000000000000000\r\n526680 1000000000000000000\r\n970200 1000000000000000000\r\n", "output": "253\r\n196\r\n157\r\n210\r\n168\r\n191\r\n222\r\n203\r\n230\r\n207\r\n231\r\n" }, { "input": "11\r\n700322 1000000000000000000\r\n999100 1000000000000000000\r\n999360 1000000000000000000\r\n999120 1048052\r\n996151 1048568\r\n978670 1048574\r\n699050 1048575\r\n611708 917442\r\n533844 1000000000000000000\r\n825752 1032192\r\n731818 966656\r\n", "output": "19\r\n42\r\n102\r\n97\r\n16\r\n79\r\n592\r\n33\r\n96\r\n52\r\n13\r\n" }, { "input": "10\r\n524287 524289\r\n524287 524289\r\n524288 524289\r\n524287 524287\r\n524289 524289\r\n524289 524289\r\n524289 524289\r\n524287 524288\r\n524287 524288\r\n524288 524288\r\n", "output": "1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n0\r\n" }, { "input": "10\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n1000000 1000000000000000000\r\n", "output": "67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n" }, { "input": "10\r\n1000000 95751431942751437\r\n1000000 926097810183045464\r\n1000000 142214244617617194\r\n1000000 227746841678946592\r\n1000000 474755439826037034\r\n1000000 394746538214101021\r\n1000000 497370130261165766\r\n1000000 53472248169215041\r\n1000000 263906845640328587\r\n1000000 267757800043962966\r\n", "output": "67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n67\r\n" }, { "input": "10\r\n16599 571759612587774316\r\n367151 801865255118311976\r\n120682 504789647279402850\r\n478728 647788353073006707\r\n944472 926234323654702405\r\n974990 774161107098645580\r\n877274 871270805936112566\r\n420469 751932137501907424\r\n131517 893613260119781644\r\n967044 985104749673945681\r\n", "output": "7\r\n6\r\n16\r\n61\r\n79\r\n21\r\n11\r\n6\r\n13\r\n40\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2008/D", "aliases": null, "contest_id": "2008", "contest_name": "Codeforces Round 970 (Div. 3)", "contest_type": "ICPC", "contest_start": 1725201300, "contest_start_year": 2024, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Sakurako's Hobby", "description": "For a certain permutation $$$p$$$$$$^{\\text{∗}}$$$ Sakurako calls an integer $$$j$$$ reachable from an integer $$$i$$$ if it is possible to make $$$i$$$ equal to $$$j$$$ by assigning $$$i=p_i$$$ a certain number of times.\n\nIf $$$p=[3,5,6,1,2,4]$$$, then, for example, $$$4$$$ is reachable from $$$1$$$, because: $$$i=1$$$ $$$\\rightarrow$$$ $$$i=p_1=3$$$ $$$\\rightarrow$$$ $$$i=p_3=6$$$ $$$\\rightarrow$$$ $$$i=p_6=4$$$. Now $$$i=4$$$, so $$$4$$$ is reachable from $$$1$$$.\n\nEach number in the permutation is colored either black or white.\n\nSakurako defines the function $$$F(i)$$$ as the number of black integers that are reachable from $$$i$$$.\n\nSakurako is interested in $$$F(i)$$$ for each $$$1\\le i\\le n$$$, but calculating all values becomes very difficult, so she asks you, as her good friend, to compute this.", "input_format": "The first line contains a single integer $$$t$$$ ($$$1\\le t\\le 10^4$$$)  — the number of test cases.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$1\\le n\\le 2\\cdot 10^5$$$)  — the number of elements in the array.\n\nThe second line of each test case contains $$$n$$$ integers $$$p_1, p_2, \\dots, p_n$$$ ($$$1\\le p_i\\le n$$$)  — the elements of the permutation.\n\nThe third line of each test case contains a string $$$s$$$ of length $$$n$$$, consisting of '0' and '1'. If $$$s_i=0$$$, then the number $$$p_i$$$ is colored black; if $$$s_i=1$$$, then the number $$$p_i$$$ is colored white.\n\nIt is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2\\cdot 10^5$$$.", "output_format": "For each test case, output $$$n$$$ integers $$$F(1), F(2), \\dots, F(n)$$$.", "interaction_format": null, "note": null, "examples": [ { "input": "5\n1\n1\n0\n5\n1 2 4 5 3\n10101\n5\n5 4 1 3 2\n10011\n6\n3 5 6 1 2 4\n010000\n6\n1 2 3 4 5 6\n100110", "output": "1 \n0 1 1 1 1 \n2 2 2 2 2 \n4 1 4 4 1 4 \n0 1 1 0 0 1" } ], "editorial": "Any permutation can be divided into some number of cycles, so $$$F(i)$$$ is equal to the number of black colored elements in the cycle where $$$i$$$ is. So, we can write out all cycles in $$$O(n)$$$ and memorize for each $$$i$$$ the number of black colored elements in the cycle where it is.", "rating": 1100, "tags": [ "dp", "dsu", "graphs", "math" ], "testset_size": 11, "official_tests": [ { "input": "5\r\n1\r\n1\r\n0\r\n5\r\n1 2 4 5 3\r\n10101\r\n5\r\n5 4 1 3 2\r\n10011\r\n6\r\n3 5 6 1 2 4\r\n010000\r\n6\r\n1 2 3 4 5 6\r\n100110\r\n", "output": "1 \r\n0 1 1 1 1 \r\n2 2 2 2 2 \r\n4 1 4 4 1 4 \r\n0 1 1 0 0 1 \r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2043/B", "aliases": null, "contest_id": "2043", "contest_name": "Educational Codeforces Round 173 (Rated for Div. 2)", "contest_type": "ICPC", "contest_start": 1735050900, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Digits", "description": "Artem wrote the digit $$$d$$$ on the board exactly $$$n!$$$ times in a row. So, he got the number $$$dddddd \\dots ddd$$$ (exactly $$$n!$$$ digits).\n\nNow he is curious about which odd digits from $$$1$$$ to $$$9$$$ divide the number written on the board.", "input_format": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 100$$$) — the number of test cases. The next $$$t$$$ test cases follow.\n\nEach test case consists of a single line containing two integers $$$n$$$ and $$$d$$$ ($$$2 \\le n \\le 10^9$$$, $$$1 \\le d \\le 9$$$).", "output_format": "For each test case, output the odd digits in ascending order that divide the number written on the board.", "interaction_format": null, "note": "The factorial of a positive integer $$$n$$$ ($$$n!$$$) is the product of all integers from $$$1$$$ to $$$n$$$. For example, the factorial of $$$5$$$ is $$$1 \\cdot 2 \\cdot 3 \\cdot 4 \\cdot 5 = 120$$$.", "examples": [ { "input": "3\n2 6\n7 1\n8 5", "output": "1 3 \n1 3 7 9 \n1 3 5 7 9" } ], "editorial": "There are several ways to solve this problem. I will describe two of them.\nUsing divisibility rules (a lot of math involved):\nWe can try divisibility rules for all odd integers from $$$1$$$ to $$$9$$$ and find out whether they work for our numbers:\n• $$$1$$$ is always the answer, since every integer is divisible by $$$1$$$:\n• a number is divisible by $$$3$$$ iff its sum of digits is divisible by $$$3$$$. Since our number consists of $$$n!$$$ digits $$$d$$$, then either $$$n!$$$ or $$$d$$$ should be divisible by $$$3$$$; so, $$$n \\ge 3$$$ or $$$d \\bmod 3 = 0$$$;\n• a number is divisible by $$$9$$$ iff its sum of digits is divisible by $$$9$$$. This is a bit trickier than the case with $$$3$$$, because it is possible that both $$$n!$$$ and $$$d$$$ are divisible by $$$3$$$ (not $$$9$$$), and it makes the sum of digits divisible by $$$9$$$;\n• a number is divisible by $$$5$$$ iff its last digit is $$$5$$$ or $$$0$$$. Just check that $$$d=5$$$, and that's it;\n• probably the trickiest case: a number is divisible by $$$7$$$ iff, when this number is split into blocks of $$$3$$$ digits (possibly with the first block shorter than $$$3$$$ digits), the sign-alternating sum of these blocks is divisible by $$$7$$$. Like, $$$1234569$$$ is divisible by $$$7$$$ because $$$(1-234+569)$$$ is divisible by $$$7$$$. If we apply this rule to our numbers from the problem, we can use the fact that when $$$n \\ge 3$$$, the number can be split into several blocks of length $$$6$$$, and each such block changes the alternating sum by $$$0$$$. So, if $$$n \\ge 3$$$ or $$$d = 7$$$, our number is divisible by $$$7$$$.\nAlmost brute force (much less math involved):\nFirst, we actually need a little bit of math. If you take a number consisting of $$$n!$$$ digits equal to $$$d$$$, it is always divisible by $$$(n-1)!$$$ digits equal to $$$d$$$. This is because, if you write some integer repeatedly, the resulting number will be divisible by the original number, like, for example, $$$424242$$$ is divisible by $$$42$$$.\nSo, if for some $$$n = k$$$, the number is divisible by some digit, then for $$$n = k+1$$$, the number will also be divisible for some digit.\nThis means that there exists an integer $$$m$$$ such that for all integers $$$n \\ge m$$$, the results are the same if you use the same digit $$$d$$$. So, we can set $$$n = \\min(n, m)$$$, and if $$$m$$$ is small enough, use brute force.\nWhat is the value of $$$m$$$? The samples tell us that the number consisting of $$$7!$$$ ones is divisible by $$$1$$$, $$$3$$$, $$$7$$$ and $$$9$$$ (and divisibility by $$$5$$$ depends only on $$$d$$$), so you can actually use $$$m=7$$$. It is also possible to reduce $$$m$$$ to $$$6$$$, but this is not required.\nSo, the solution is: reduce $$$n$$$ to something like $$$7$$$ if it is greater than $$$7$$$, then use brute force. You can either calculate the remainder of a big number modulo small number using a for-loop, or, if you code in Java or Python, use built-in big integers (just be careful with Python, modern versions of it forbid some operations with integers longer than $$$4300$$$ digits, you might need to override that behavior).", "rating": 1100, "tags": [ "math", "number theory" ], "testset_size": 6, "official_tests": [ { "input": "3\r\n2 6\r\n7 1\r\n8 5\r\n", "output": "1 3 \r\n1 3 7 9 \r\n1 3 5 7 9 \r\n" }, { "input": "9\r\n1000000000 1\r\n1000000000 2\r\n1000000000 3\r\n1000000000 4\r\n1000000000 5\r\n1000000000 6\r\n1000000000 7\r\n1000000000 8\r\n1000000000 9\r\n", "output": "1 3 7 9 \r\n1 3 7 9 \r\n1 3 7 9 \r\n1 3 7 9 \r\n1 3 5 7 9 \r\n1 3 7 9 \r\n1 3 7 9 \r\n1 3 7 9 \r\n1 3 7 9 \r\n" }, { "input": "3\r\n5388586 7\r\n1625078 5\r\n548212 3\r\n", "output": "1 3 7 9 \r\n1 3 5 7 9 \r\n1 3 7 9 \r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2021/B", "aliases": null, "contest_id": "2021", "contest_name": "Codeforces Round 977 (Div. 2, based on COMPFEST 16 - Final Round)", "contest_type": "CF", "contest_start": 1728194700, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Maximize Mex", "description": "You are given an array $$$a$$$ of $$$n$$$ positive integers and an integer $$$x$$$. You can do the following two-step operation any (possibly zero) number of times:\n\n1. Choose an index $$$i$$$ ($$$1 \\leq i \\leq n$$$).\n2. Increase $$$a_i$$$ by $$$x$$$, in other words $$$a_i := a_i + x$$$.\n\nFind the maximum value of the $$$\\operatorname{MEX}$$$ of $$$a$$$ if you perform the operations optimally.\n\nThe $$$\\operatorname{MEX}$$$ (minimum excluded value) of an array is the smallest non-negative integer that is not in the array. For example:\n\n- The $$$\\operatorname{MEX}$$$ of $$$[2,2,1]$$$ is $$$0$$$ because $$$0$$$ is not in the array.\n- The $$$\\operatorname{MEX}$$$ of $$$[3,1,0,1]$$$ is $$$2$$$ because $$$0$$$ and $$$1$$$ are in the array but $$$2$$$ is not.\n- The $$$\\operatorname{MEX}$$$ of $$$[0,3,1,2]$$$ is $$$4$$$ because $$$0$$$, $$$1$$$, $$$2$$$ and $$$3$$$ are in the array but $$$4$$$ is not.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 5000$$$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$; $$$1 \\le x \\le 10^9$$$) — the length of the array and the integer to be used in the operation.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\le a_i \\le 10^9$$$) — the given array.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output a single integer: the maximum $$$\\operatorname{MEX}$$$ of $$$a$$$ if you perform the operations optimally.", "interaction_format": null, "note": "In the first test case, the $$$\\operatorname{MEX}$$$ of $$$a$$$ is $$$4$$$ without performing any operations, which is the maximum.\n\nIn the second test case, the $$$\\operatorname{MEX}$$$ of $$$a$$$ is $$$5$$$ without performing any operations. If we perform two operations both with $$$i=1$$$, we will have the array $$$a=[5,3,4,1,0,2]$$$. Then, the $$$\\operatorname{MEX}$$$ of $$$a$$$ will become $$$6$$$, which is the maximum.\n\nIn the third test case, the $$$\\operatorname{MEX}$$$ of $$$a$$$ is $$$0$$$ without performing any operations, which is the maximum.", "examples": [ { "input": "3\n6 3\n0 3 2 1 5 2\n6 2\n1 3 4 1 0 2\n4 5\n2 5 10 3", "output": "4\n6\n0" } ], "editorial": "For the $$$\\operatorname{MEX}$$$ to be at least $$$k$$$, then each non-negative integer from $$$0$$$ to $$$k-1$$$ must appear at least once in the array.\nFirst, notice that since there are only $$$n$$$ elements in the array, there are at most $$$n$$$ different values, so the $$$\\operatorname{MEX}$$$ can only be at most $$$n$$$. And since we can only increase an element's value, that means every element with values bigger than $$$n$$$ can be ignored.\nWe construct a frequency array $$$\\text{freq}$$$ such that $$$\\text{freq}[k]$$$ is the number of elements in $$$a$$$ with value $$$k$$$.\nNotice that the values just need to appear at least once to contribute to the $$$\\operatorname{MEX}$$$, so two or more elements with the same value should be split into different values to yield a potentially better result. To find the maximum possible $$$\\operatorname{MEX}$$$, we iterate each index $$$k$$$ in the array $$$\\text{freq}$$$ from $$$0$$$ to $$$n$$$. In each iteration of $$$k$$$, if we find $$$\\text{freq[k]}>0$$$, that means it's possible to have the $$$\\operatorname{MEX}$$$ be bigger than $$$k$$$, so we can iterate $$$k$$$ to the next value. Before we iterate to the next value, if we find $$$\\text{freq}[k]>1$$$, that indicates duplicates, so we should do an operation to all except one of those values to change them into $$$k+x$$$, which increases $$$\\text{freq}[k+x]$$$ by $$$\\text{freq}[k]-1$$$ and changes $$$\\text{freq}[k]$$$ into $$$1$$$. In each iteration of $$$k$$$, if we find $$$\\text{freq}[k]=0$$$, that means, $$$k$$$ is the maximum $$$\\operatorname{MEX}$$$ we can get, and we should end the process.\nTime complexity for each test case: $$$O(n)$$$", "rating": 1200, "tags": [ "brute force", "greedy", "math", "number theory" ], "testset_size": 14, "official_tests": [ { "input": "3\r\n6 3\r\n0 3 2 1 5 2\r\n6 2\r\n1 3 4 1 0 2\r\n4 5\r\n2 5 10 3\r\n", "output": "4\r\n6\r\n0\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2014/C", "aliases": null, "contest_id": "2014", "contest_name": "Codeforces Round 974 (Div. 3)", "contest_type": "ICPC", "contest_start": 1726929900, "contest_start_year": 2024, "index": "C", "time_limit": 2.0, "memory_limit": 256.0, "title": "Robin Hood in Town", "description": "Look around, the rich are getting richer, and the poor are getting poorer. We need to take from the rich and give to the poor. We need Robin Hood!\n\nThere are $$$n$$$ people living in the town. Just now, the wealth of the $$$i$$$-th person was $$$a_i$$$ gold. But guess what? The richest person has found an extra pot of gold!\n\nMore formally, find an $$$a_j=max(a_1, a_2, \\dots, a_n)$$$, change $$$a_j$$$ to $$$a_j+x$$$, where $$$x$$$ is a non-negative integer number of gold found in the pot. If there are multiple maxima, it can be any one of them.\n\nA person is unhappy if their wealth is strictly less than half of the average wealth$$$^{\\text{∗}}$$$.\n\nIf strictly more than half of the total population $$$n$$$ are unhappy, Robin Hood will appear by popular demand.\n\nDetermine the minimum value of $$$x$$$ for Robin Hood to appear, or output $$$-1$$$ if it is impossible.", "input_format": "The first line of input contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains an integer $$$n$$$ ($$$1 \\le n \\le 2\\cdot10^5$$$) — the total population.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^6$$$) — the wealth of each person.\n\nIt is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output one integer — the minimum number of gold that the richest person must find for Robin Hood to appear. If it is impossible, output $$$-1$$$ instead.", "interaction_format": null, "note": "In the first test case, it is impossible for a single person to be unhappy.\n\nIn the second test case, there is always $$$1$$$ happy person (the richest).\n\nIn the third test case, no additional gold are required, so the answer is $$$0$$$.\n\nIn the fourth test case, after adding $$$15$$$ gold, the average wealth becomes $$$\\frac{25}{4}$$$, and half of this average is $$$\\frac{25}{8}$$$, resulting in $$$3$$$ people being unhappy.\n\nIn the fifth test case, after adding $$$16$$$ gold, the average wealth becomes $$$\\frac{31}{5}$$$, resulting in $$$3$$$ people being unhappy.", "examples": [ { "input": "6\n1\n2\n2\n2 19\n3\n1 3 20\n4\n1 2 3 4\n5\n1 2 3 4 5\n6\n1 2 1 1 1 25", "output": "-1\n-1\n0\n15\n16\n0" } ], "editorial": "We need to check if $$$w_i < \\frac{sum(w)}{2*n}$$$. It is recommended to keep operations in integers, so we check if $$$w_i*2*n < sum(w)$$$. Once we find the number of unhappy people, $$$n_{unhappy}$$$, we check if $$$n_{unhappy}*2 > n$$$.", "rating": 1100, "tags": [ "binary search", "greedy", "math" ], "testset_size": 9, "official_tests": [ { "input": "6\r\n1\r\n2\r\n2\r\n2 19\r\n3\r\n1 3 20\r\n4\r\n1 2 3 4\r\n5\r\n1 2 3 4 5\r\n6\r\n1 2 1 1 1 25\r\n", "output": "-1\r\n-1\r\n0\r\n15\r\n16\r\n0\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2025/B", "aliases": null, "contest_id": "2025", "contest_name": "Educational Codeforces Round 170 (Rated for Div. 2)", "contest_type": "ICPC", "contest_start": 1728916500, "contest_start_year": 2024, "index": "B", "time_limit": 2.0, "memory_limit": 512.0, "title": "Binomial Coefficients, Kind Of", "description": "Recently, akshiM met a task that needed binomial coefficients to solve. He wrote a code he usually does that looked like this:\n\nUnfortunately, he made an error, since the right formula is the following:\n\nBut his team member keblidA is interested in values that were produced using the wrong formula. Please help him to calculate these coefficients for $$$t$$$ various pairs $$$(n_i, k_i)$$$. Note that they should be calculated according to the first (wrong) formula.\n\nSince values $$$C[n_i][k_i]$$$ may be too large, print them modulo $$$10^9 + 7$$$.", "input_format": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^5$$$) — the number of pairs. Next, $$$t$$$ pairs are written in two lines.\n\nThe second line contains $$$t$$$ integers $$$n_1, n_2, \\dots, n_t$$$ ($$$2 \\le n_i \\le 10^5$$$).\n\nThe third line contains $$$t$$$ integers $$$k_1, k_2, \\dots, k_t$$$ ($$$1 \\le k_i < n_i$$$).", "output_format": "Print $$$t$$$ integers $$$C[n_i][k_i]$$$ modulo $$$10^9 + 7$$$.", "interaction_format": null, "note": null, "examples": [ { "input": "7\n2 5 5 100000 100000 100000 100000\n1 2 3 1 33333 66666 99999", "output": "2\n4\n8\n2\n326186014\n984426998\n303861760" } ], "editorial": "In order to solve the task, just try to generate values and find a pattern. The pattern is easy: $$$C[n][k] = 2^k$$$ for all $$$k \\in [0, n)$$$.\nThe last step is to calculate $$$C[n][k]$$$ fast enough. For example, we can precalculate all powers of two in some array $$$p$$$ as $$$p[k] = 2 \\cdot p[k - 1] \\bmod (10^9 + 7)$$$ for all $$$k < 10^5$$$ and print the necessary values when asked.\nProof:\n$$$$$$C[n][k] = C[n][k - 1] + C[n - 1][k - 1] = $$$$$$ $$$$$$ = C[n][k - 2] + 2 \\cdot C[n - 1][k - 2] + C[n - 2][k - 2] = $$$$$$ $$$$$$ = C[n][k - 3] + 3 \\cdot C[n - 1][k - 3] + 3 \\cdot C[n - 2][k - 3] + C[n - 3][k - 3] = $$$$$$ $$$$$$ = \\sum_{i = 0}^{j}{\\binom{j}{i} \\cdot C[n - i][k - j]} = \\sum_{i = 0}^{k}{\\binom{k}{i} \\cdot C[n - i][0]} = \\sum_{i = 0}^{k}{\\binom{k}{i}} = 2^k$$$$$$", "rating": 1100, "tags": [ "combinatorics", "dp", "math" ], "testset_size": 17, "official_tests": [ { "input": "7\r\n2 5 5 100000 100000 100000 100000\r\n1 2 3 1 33333 66666 99999\r\n", "output": "2\r\n4\r\n8\r\n2\r\n326186014\r\n984426998\r\n303861760\r\n" }, { "input": "25\r\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\r\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\r\n", "output": "2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n2\r\n" }, { "input": "7\r\n2 3 4 5 6 7 8\r\n1 2 3 4 5 6 7\r\n", "output": "2\r\n4\r\n8\r\n16\r\n32\r\n64\r\n128\r\n" }, { "input": "25\r\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\r\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\r\n", "output": "4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n4\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2029/B", "aliases": null, "contest_id": "2029", "contest_name": "Refact.ai Match 1 (Codeforces Round 985)", "contest_type": "CF", "contest_start": 1731162900, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Replacement", "description": "You have a binary string$$$^{\\text{∗}}$$$ $$$s$$$ of length $$$n$$$, and Iris gives you another binary string $$$r$$$ of length $$$n-1$$$.\n\nIris is going to play a game with you. During the game, you will perform $$$n-1$$$ operations on $$$s$$$. In the $$$i$$$-th operation ($$$1 \\le i \\le n-1$$$):\n\n- First, you choose an index $$$k$$$ such that $$$1\\le k\\le |s| - 1$$$ and $$$s_{k} \\neq s_{k+1}$$$. If it is impossible to choose such an index, you lose;\n- Then, you replace $$$s_ks_{k+1}$$$ with $$$r_i$$$. Note that this decreases the length of $$$s$$$ by $$$1$$$.\n\nIf all the $$$n-1$$$ operations are performed successfully, you win.\n\nDetermine whether it is possible for you to win this game.", "input_format": "Each test contains multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1\\le t\\le 10^4$$$) — the number of test cases. The description of test cases follows.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$2\\le n\\le 10^5$$$) — the length of $$$s$$$.\n\nThe second line contains the binary string $$$s$$$ of length $$$n$$$ ($$$s_i=\\mathtt{0}$$$ or $$$\\mathtt{1}$$$).\n\nThe third line contains the binary string $$$r$$$ of length $$$n-1$$$ ($$$r_i=\\mathtt{0}$$$ or $$$\\mathtt{1}$$$).\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.", "output_format": "For each test case, print \"YES\" (without quotes) if you can win the game, and \"NO\" (without quotes) otherwise.\n\nYou can output the answer in any case (upper or lower). For example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as positive responses.", "interaction_format": null, "note": "In the first test case, you cannot perform the first operation. Thus, you lose the game.\n\nIn the second test case, you can choose $$$k=1$$$ in the only operation, and after that, $$$s$$$ becomes equal to $$$\\mathtt{1}$$$. Thus, you win the game.\n\nIn the third test case, you can perform the following operations: $$$\\mathtt{1}\\underline{\\mathtt{10}}\\mathtt{1}\\xrightarrow{r_1=\\mathtt{0}} \\mathtt{1}\\underline{\\mathtt{01}} \\xrightarrow{r_2=\\mathtt{0}} \\underline{\\mathtt{10}} \\xrightarrow{r_3=\\mathtt{1}} \\mathtt{1}$$$.", "examples": [ { "input": "6\n2\n11\n0\n2\n01\n1\n4\n1101\n001\n6\n111110\n10000\n6\n010010\n11010\n8\n10010010\n0010010", "output": "NO\nYES\nYES\nNO\nYES\nNO" } ], "editorial": null, "rating": 1100, "tags": [ "constructive algorithms", "games", "strings" ], "testset_size": 16, "official_tests": [ { "input": "6\r\n2\r\n11\r\n0\r\n2\r\n01\r\n1\r\n4\r\n1101\r\n001\r\n6\r\n111110\r\n10000\r\n6\r\n010010\r\n11010\r\n8\r\n10010010\r\n0010010\r\n", "output": "NO\r\nYES\r\nYES\r\nNO\r\nYES\r\nNO\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2062/C", "aliases": null, "contest_id": "2062", "contest_name": "Ethflow Round 1 (Codeforces Round 1001, Div. 1 + Div. 2)", "contest_type": "CF", "contest_start": 1737902100, "contest_start_year": 2025, "index": "C", "time_limit": 2.0, "memory_limit": 512.0, "title": "Cirno and Operations", "description": "Cirno has a sequence $$$a$$$ of length $$$n$$$. She can perform either of the following two operations for any (possibly, zero) times unless the current length of $$$a$$$ is $$$1$$$:\n\n- Reverse the sequence. Formally, $$$[a_1,a_2,\\ldots,a_n]$$$ becomes $$$[a_n,a_{n-1},\\ldots,a_1]$$$ after the operation.\n- Replace the sequence with its difference sequence. Formally, $$$[a_1,a_2,\\ldots,a_n]$$$ becomes $$$[a_2-a_1,a_3-a_2,\\ldots,a_n-a_{n-1}]$$$ after the operation.\n\nFind the maximum possible sum of elements of $$$a$$$ after all operations.", "input_format": "The first line of input contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 100$$$) — the number of input test cases.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$1\\le n\\le 50$$$) — the length of sequence $$$a$$$.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\\ldots,a_n$$$ ($$$|a_i|\\le 1000$$$) — the sequence $$$a$$$.", "output_format": "For each test case, print an integer representing the maximum possible sum.", "interaction_format": null, "note": "In the first test case, Cirno can not perform any operation, so the answer is $$$-1000$$$.\n\nIn the second test case, Cirno firstly reverses the sequence, then replaces the sequence with its difference sequence: $$$[5,-3]\\to[-3,5]\\to[8]$$$. It can be proven that this maximizes the sum, so the answer is $$$8$$$.\n\nIn the third test case, Cirno can choose not to operate, so the answer is $$$1001$$$.", "examples": [ { "input": "5\n1\n-1000\n2\n5 -3\n2\n1000 1\n9\n9 7 9 -9 9 -8 7 -8 9\n11\n678 201 340 444 453 922 128 987 127 752 0", "output": "-1000\n8\n1001\n2056\n269891" } ], "editorial": "Let the reversal be called operation $$$1$$$, and the difference be called operation $$$2$$$. Consider swapping two adjacent operations: $$$12 \\to 21$$$. If the sequence before the operations is $$$[a_1, a_2, \\dots, a_n]$$$, then after the operations, the sequence changes from $$$[a_{n-1} - a_n, a_{n-2} - a_{n-1}, \\dots, a_1 - a_2]$$$ to $$$[a_n - a_{n-1}, a_{n-1} - a_{n-2}, \\dots, a_2 - a_1]$$$. Thus, swapping adjacent $$$1,2$$$ is equivalent to taking the negation of each element of the array.\nTherefore, any operation sequence is equivalent to first performing $$$2$$$ several times, and then performing $$$1$$$ several times, and then taking the negation several times. Since $$$1$$$ does not change the sum of the sequence, the answer is the maximum absolute value of the sequence sum after performing a certain number of $$$2$$$.\nThere is a corner case: if you don't perform $$$2$$$ at all, you can not take the negation. Besides, the upper bound of the answer is $$$1000\\times 2^{50}$$$, so you have to use 64-bit integers.", "rating": 1200, "tags": [ "brute force", "math" ], "testset_size": 11, "official_tests": [ { "input": "5\r\n1\r\n-1000\r\n2\r\n5 -3\r\n2\r\n1000 1\r\n9\r\n9 7 9 -9 9 -8 7 -8 9\r\n11\r\n678 201 340 444 453 922 128 987 127 752 0\r\n", "output": "-1000\r\n8\r\n1001\r\n2056\r\n269891\r\n" }, { "input": "1\r\n50\r\n717 -645 152 121 135 628 495 592 -52 -159 264 -569 702 873 909 -241 -938 -796 23 -534 -174 -870 112 -764 766 270 -310 498 -191 864 -853 665 -152 -73 -578 22 -92 -612 -375 -258 -758 813 -435 583 -412 512 -434 -998 223 484\r\n", "output": "27153791918919530\r\n" }, { "input": "1\r\n6\r\n-4 -5 -6 -7 -8 -9\r\n", "output": "5\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2053/B", "aliases": null, "contest_id": "2053", "contest_name": "Good Bye 2024: 2025 is NEAR", "contest_type": "CF", "contest_start": 1735396500, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Outstanding Impressionist", "description": "Even after copying the paintings from famous artists for ten years, unfortunately, Eric is still unable to become a skillful impressionist painter. He wants to forget something, but the white bear phenomenon just keeps hanging over him.\n\nEric still remembers $$$n$$$ pieces of impressions in the form of an integer array. He records them as $$$w_1, w_2, \\ldots, w_n$$$. However, he has a poor memory of the impressions. For each $$$1 \\leq i \\leq n$$$, he can only remember that $$$l_i \\leq w_i \\leq r_i$$$.\n\nEric believes that impression $$$i$$$ is unique if and only if there exists a possible array $$$w_1, w_2, \\ldots, w_n$$$ such that $$$w_i \\neq w_j$$$ holds for all $$$1 \\leq j \\leq n$$$ with $$$j \\neq i$$$.\n\nPlease help Eric determine whether impression $$$i$$$ is unique for every $$$1 \\leq i \\leq n$$$, independently for each $$$i$$$. Perhaps your judgment can help rewrite the final story.", "input_format": "Each test contains multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases. The description of test cases follows.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 2\\cdot 10^5$$$) — the number of impressions.\n\nThen $$$n$$$ lines follow, the $$$i$$$-th containing two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \\leq l_i \\leq r_i \\leq 2\\cdot n$$$) — the minimum possible value and the maximum possible value of $$$w_i$$$.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\\cdot 10^5$$$.", "output_format": "For each test case, output a binary string $$$s$$$ of length $$$n$$$: for each $$$1 \\leq i \\leq n$$$, if impression $$$i$$$ is unique, $$$s_i=\\texttt{1}$$$; otherwise, $$$s_i=\\texttt{0}$$$. Do not output spaces.", "interaction_format": null, "note": "In the first test case, the only possible array $$$w$$$ is $$$[1, 1]$$$, making neither impression $$$1$$$ nor $$$2$$$ unique (since $$$w_1 = w_2$$$).\n\nIn the second test case, all impressions can be made unique:\n\n- For $$$i = 1$$$, we can set $$$w$$$ to $$$[1, 3, 2, 3]$$$, in which $$$w_1 \\neq w_2$$$, $$$w_1 \\neq w_3$$$, and $$$w_1 \\neq w_4$$$;\n- For $$$i = 2$$$, we can set $$$w$$$ to $$$[2, 3, 1, 2]$$$, in which $$$w_2 \\neq w_1$$$, $$$w_2 \\neq w_3$$$, and $$$w_2 \\neq w_4$$$;\n- For $$$i = 3$$$, we can set $$$w$$$ to $$$[1, 1, 3, 1]$$$;\n- For $$$i = 4$$$, we can set $$$w$$$ to $$$[2, 3, 3, 1]$$$.\n\nIn the third test case, for $$$i = 4$$$, we can set $$$w$$$ to $$$[3, 2, 2, 1, 3, 2]$$$. Thus, impression $$$4$$$ is unique.", "examples": [ { "input": "5\n2\n1 1\n1 1\n4\n1 3\n1 3\n1 3\n1 3\n6\n3 6\n2 2\n1 2\n1 1\n3 4\n2 2\n7\n3 4\n4 4\n4 4\n1 3\n2 5\n1 4\n2 2\n3\n4 5\n4 4\n5 5", "output": "00\n1111\n100110\n1001111\n011" } ], "editorial": "For each $$$1 \\leq i \\leq n$$$, for each $$$l_i \\leq x \\leq r_i$$$, we want to check if it is okay for $$$w_i$$$ being unique at the value of $$$x$$$: for each $$$j \\neq i$$$, we can always switch $$$w_j$$$ to a value different from $$$x$$$ if $$$l_j \\neq r_j$$$; so if $$$l_j = r_j = x$$$ it's always invalid, otherwise it's okay.\nTherefore, impression $$$i$$$ may contribute to a $$$\\texttt{NO}$$$ only when it is fixed, that is, $$$l_i = r_i$$$.\nLet's record $$$a_i$$$ as the number of different $$$k$$$ satisfying $$$1 \\leq k \\leq n$$$, $$$l_k = r_k = i$$$. If $$$l_i \\neq r_i$$$, then we say impression $$$i$$$ cannot be made unique if and only if for all $$$l_i \\leq k \\leq r_i$$$, $$$a_k \\geq 1$$$; and if $$$l_i = r_i$$$, it cannot be unique if and only if $$$a_{l_i} \\geq 2$$$.\nThis can all be checked quickly within a prefix sum, so the overall time complexity is $$$\\mathcal O(\\sum n)$$$.", "rating": 1200, "tags": [ "binary search", "brute force", "data structures", "greedy" ], "testset_size": 15, "official_tests": [ { "input": "5\r\n2\r\n1 1\r\n1 1\r\n4\r\n1 3\r\n1 3\r\n1 3\r\n1 3\r\n6\r\n3 6\r\n2 2\r\n1 2\r\n1 1\r\n3 4\r\n2 2\r\n7\r\n3 4\r\n4 4\r\n4 4\r\n1 3\r\n2 5\r\n1 4\r\n2 2\r\n3\r\n4 5\r\n4 4\r\n5 5\r\n", "output": "00\r\n1111\r\n100110\r\n1001111\r\n011\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "1999/D", "aliases": null, "contest_id": "1999", "contest_name": "Codeforces Round 964 (Div. 4)", "contest_type": "ICPC", "contest_start": 1722954900, "contest_start_year": 2024, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Slavic's Exam", "description": "Slavic has a very tough exam and needs your help in order to pass it. Here is the question he is struggling with:\n\nThere exists a string $$$s$$$, which consists of lowercase English letters and possibly zero or more \"?\".\n\nSlavic is asked to change each \"?\" to a lowercase English letter such that string $$$t$$$ becomes a subsequence (not necessarily continuous) of the string $$$s$$$.\n\nOutput any such string, or say that it is impossible in case no string that respects the conditions exists.", "input_format": "The first line contains a single integer $$$T$$$ ($$$1 \\leq T \\leq 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains a single string $$$s$$$ ($$$1 \\leq |s| \\leq 2 \\cdot 10^5$$$, and $$$s$$$ consists only of lowercase English letters and \"?\"-s)  – the original string you have.\n\nThe second line of each test case contains a single string $$$t$$$ ($$$1 \\leq |t| \\leq |s|$$$, and $$$t$$$ consists only of lowercase English letters)  – the string that should be a subsequence of string $$$s$$$.\n\nThe sum of $$$|s|$$$ over all test cases doesn't exceed $$$2 \\cdot 10^5$$$, where $$$|x|$$$ denotes the length of the string $$$x$$$.", "output_format": "For each test case, if no such string exists as described in the statement, output \"NO\" (without quotes).\n\nOtherwise, output \"YES\" (without quotes). Then, output one line — the string that respects all conditions.\n\nYou can output \"YES\" and \"NO\" in any case (for example, strings \"yEs\", \"yes\", and \"Yes\" will be recognized as a positive response).\n\nIf multiple answers are possible, you can output any of them.", "interaction_format": null, "note": null, "examples": [ { "input": "5\n?????\nxbx\nab??e\nabcde\nayy?x\na\nab??e\ndac\npaiu\nmom", "output": "YES\nxabax\nYES\nabcde\nYES\nayyyx\nNO\nNO" } ], "editorial": "Let's use a greedy strategy with two pointers, one at the start of $$$s$$$ (called $$$i$$$) and one at the start of $$$t$$$ (called $$$j$$$). At each step, advance $$$i$$$ by $$$1$$$. If $$$s_i = \\texttt{?}$$$, then we set it to $$$t_j$$$ and increment $$$j$$$. If $$$s_i = t_j$$$ then we also increment $$$j$$$ (because there is a match).\nIt works because if there is ever a question mark, it never makes it worse to match the current character in $$$t$$$ earlier than later. The complexity is $$$\\mathcal{O}(n)$$$.", "rating": 1100, "tags": [ "greedy", "implementation", "strings" ], "testset_size": 29, "official_tests": [ { "input": "5\r\n?????\r\nxbx\r\nab??e\r\nabcde\r\nayy?x\r\na\r\nab??e\r\ndac\r\npaiu\r\nmom\r\n", "output": "YES\r\nxbxaa\r\nYES\r\nabcde\r\nYES\r\nayyax\r\nNO\r\nNO\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2000/D", "aliases": null, "contest_id": "2000", "contest_name": "Codeforces Round 966 (Div. 3)", "contest_type": "ICPC", "contest_start": 1723560000, "contest_start_year": 2024, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Right Left Wrong", "description": "Vlad found a strip of $$$n$$$ cells, numbered from left to right from $$$1$$$ to $$$n$$$. In the $$$i$$$-th cell, there is a positive integer $$$a_i$$$ and a letter $$$s_i$$$, where all $$$s_i$$$ are either 'L' or 'R'.\n\nVlad invites you to try to score the maximum possible points by performing any (possibly zero) number of operations.\n\nIn one operation, you can choose two indices $$$l$$$ and $$$r$$$ ($$$1 \\le l < r \\le n$$$) such that $$$s_l$$$ = 'L' and $$$s_r$$$ = 'R' and do the following:\n\n- add $$$a_l + a_{l + 1} + \\dots + a_{r - 1} + a_r$$$ points to the current score;\n- replace $$$s_i$$$ with '.' for all $$$l \\le i \\le r$$$, meaning you can no longer choose these indices.\n\nFor example, consider the following strip:\n\n$$$3$$$$$$5$$$$$$1$$$$$$4$$$$$$3$$$$$$2$$$LRLLLR\n\nYou can first choose $$$l = 1$$$, $$$r = 2$$$ and add $$$3 + 5 = 8$$$ to your score.\n\n$$$3$$$$$$5$$$$$$1$$$$$$4$$$$$$3$$$$$$2$$$..LLLR\n\nThen choose $$$l = 3$$$, $$$r = 6$$$ and add $$$1 + 4 + 3 + 2 = 10$$$ to your score.\n\n$$$3$$$$$$5$$$$$$1$$$$$$4$$$$$$3$$$$$$2$$$......\n\nAs a result, it is impossible to perform another operation, and the final score is $$$18$$$.\n\nWhat is the maximum score that can be achieved?", "input_format": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains one integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$) — the length of the strip.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^5$$$) — the numbers written on the strip.\n\nThe third line of each test case contains a string $$$s$$$ of $$$n$$$ characters 'L' and 'R'.\n\nIt is guaranteed that the sum of the values of $$$n$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output one integer — the maximum possible number of points that can be scored.", "interaction_format": null, "note": null, "examples": [ { "input": "4\n6\n3 5 1 4 3 2\nLRLLLR\n2\n2 8\nLR\n2\n3 9\nRL\n5\n1 2 3 4 5\nLRLRR", "output": "18\n10\n0\n22" } ], "editorial": "Note that since all characters of the selected segment of the string $$$s$$$ are erased after applying the operation, the segments we choose cannot overlap. However, they can be nested if we first choose an inner segment and then an outer one.\nSince all numbers in the array are positive, it is always beneficial to take the largest possible segment in the answer, that is, from the first 'L' to the last 'R'. By choosing this segment, we can only select segments within it. We will continue to choose such segments within the last selected one as long as possible. To quickly find the sums of the segments, we will calculate the prefix sums of the array $$$a$$$.", "rating": 1200, "tags": [ "greedy", "implementation", "two pointers" ], "testset_size": 19, "official_tests": [ { "input": "4\r\n6\r\n3 5 1 4 3 2\r\nLRLLLR\r\n2\r\n2 8\r\nLR\r\n2\r\n3 9\r\nRL\r\n5\r\n1 2 3 4 5\r\nLRLRR\r\n", "output": "18\r\n10\r\n0\r\n22\r\n" }, { "input": "1\r\n5\r\n1 2 3 4 5\r\nRRRRR\r\n", "output": "0\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2004/C", "aliases": null, "contest_id": "2004", "contest_name": "Educational Codeforces Round 169 (Rated for Div. 2)", "contest_type": "ICPC", "contest_start": 1723732500, "contest_start_year": 2024, "index": "C", "time_limit": 2.0, "memory_limit": 256.0, "title": "Splitting Items", "description": "Alice and Bob have $$$n$$$ items they'd like to split between them, so they decided to play a game. All items have a cost, and the $$$i$$$-th item costs $$$a_i$$$. Players move in turns starting from Alice.\n\nIn each turn, the player chooses one of the remaining items and takes it. The game goes on until no items are left.\n\nLet's say that $$$A$$$ is the total cost of items taken by Alice and $$$B$$$ is the total cost of Bob's items. The resulting score of the game then will be equal to $$$A - B$$$.\n\nAlice wants to maximize the score, while Bob wants to minimize it. Both Alice and Bob will play optimally.\n\nBut the game will take place tomorrow, so today Bob can modify the costs a little. He can increase the costs $$$a_i$$$ of several (possibly none or all) items by an integer value (possibly, by the same value or by different values for each item). However, the total increase must be less than or equal to $$$k$$$. Otherwise, Alice may suspect something. Note that Bob can't decrease costs, only increase.\n\nWhat is the minimum possible score Bob can achieve?", "input_format": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 5000$$$) — the number of test cases. Then $$$t$$$ cases follow.\n\nThe first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$; $$$0 \\le k \\le 10^9$$$) — the number of items and the maximum total increase Bob can make.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) — the initial costs of the items.\n\nIt's guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, print a single integer — the minimum possible score $$$A - B$$$ after Bob increases the costs of several (possibly none or all) items.", "interaction_format": null, "note": "In the first test case, Bob can increase $$$a_1$$$ by $$$5$$$, making costs equal to $$$[6, 10]$$$. Tomorrow, Alice will take $$$10$$$ and Bob will take $$$6$$$. The total score will be equal to $$$10 - 6 = 4$$$, and it's the minimum possible.\n\nIn the second test case, Bob can't change costs. So the score will be equal to $$$(15 + 10) - 12 = 13$$$, since Alice will take $$$15$$$, Bob will take $$$12$$$, and Alice — $$$10$$$.\n\nIn the third test case, Bob, for example, can increase $$$a_1$$$ by $$$1$$$, $$$a_2$$$ by $$$3$$$, and $$$a_3$$$ by $$$2$$$. The total change is equal to $$$1 + 3 + 2 \\le 6$$$ and costs will be equal to $$$[4, 4, 4, 4]$$$. Obviously, the score will be equal to $$$(4 + 4) - (4 + 4) = 0$$$.\n\nIn the fourth test case, Bob can increase $$$a_1$$$ by $$$3$$$, making costs equal to $$$[9, 9]$$$. The score will be equal to $$$9 - 9 = 0$$$.", "examples": [ { "input": "4\n2 5\n1 10\n3 0\n10 15 12\n4 6\n3 1 2 4\n2 4\n6 9", "output": "4\n13\n0\n0" } ], "editorial": "Let's sort the array in descending order and consider the first two moves of the game.\nSince Alice goes first, she takes the maximum element in the array ($$$a_1$$$). Then, during his turn, Bob takes the second-largest element ($$$a_2$$$) to minimize the score difference.\nBob can increase his element in advance; however, he cannot make it larger than $$$a_1$$$ (since Alice always takes the maximum element in the array). This means that Bob needs to increase his element to $$$\\min(a_1, a_2 + k)$$$. Then the game moves to a similar situation, but without the first two elements and with an updated value of $$$k$$$.\nThus, to solve the problem, we can sort the array and then iterate through it while maintaining several values. If the current index is odd (corresponding to Alice's turn), increase the answer by $$$a_i$$$. If the current index is even (corresponding to Bob's turn), increase the current value of $$$a_i$$$ by $$$\\min(k, a_{i - 1} - a_i)$$$, decrease $$$k$$$ by that same value, and also subtract the new value of $$$a_i$$$ from the answer.", "rating": 1100, "tags": [ "games", "greedy", "sortings" ], "testset_size": 24, "official_tests": [ { "input": "4\r\n2 5\r\n1 10\r\n3 0\r\n10 15 12\r\n4 6\r\n3 1 2 4\r\n2 4\r\n6 9\r\n", "output": "4\r\n13\r\n0\r\n0\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "1993/B", "aliases": null, "contest_id": "1993", "contest_name": "Codeforces Round 963 (Div. 2)", "contest_type": "CF", "contest_start": 1722782100, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Parity and Sum", "description": "Given an array $$$a$$$ of $$$n$$$ positive integers.\n\nIn one operation, you can pick any pair of indexes $$$(i, j)$$$ such that $$$a_i$$$ and $$$a_j$$$ have distinct parity, then replace the smaller one with the sum of them. More formally:\n\n- If $$$a_i < a_j$$$, replace $$$a_i$$$ with $$$a_i + a_j$$$;\n- Otherwise, replace $$$a_j$$$ with $$$a_i + a_j$$$.\n\nFind the minimum number of operations needed to make all elements of the array have the same parity.", "input_format": "The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$).\n\nThe second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$) — the elements of array $$$a$$$.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output a single integer — the minimum number of operations required.", "interaction_format": null, "note": "In the first test case, all integers already have the same parity. Therefore, no operation is needed.\n\nIn the third test case, we can perform two operations $$$(1, 2)$$$ and $$$(1, 3)$$$. The array $$$a$$$ transforms as follows: $$$a = [\\color{red}2, \\color{red}3, 4] \\longrightarrow [\\color{red}5, 3, \\color{red}4] \\longrightarrow [5, 3, 9]$$$.\n\nIn the fourth test case, an example of an optimal sequence of operations is $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(1, 4)$$$, and $$$(1, 4)$$$. The array $$$a$$$ transforms as follows: $$$a = [\\color{red}3, \\color{red}2, 2, 8] \\longrightarrow [\\color{red}3, 5, \\color{red}2, 8] \\longrightarrow [\\color{red}3, 5, 5, \\color{red}8] \\longrightarrow [\\color{red}{11}, 5, 5, \\color{red}8] \\longrightarrow [11, 5, 5, 19]$$$.", "examples": [ { "input": "7\n5\n1 3 5 7 9\n4\n4 4 4 4\n3\n2 3 4\n4\n3 2 2 8\n6\n4 3 6 1 2 1\n6\n3 6 1 2 1 2\n5\n999999996 999999997 999999998 999999999 1000000000", "output": "0\n0\n2\n4\n3\n3\n3" } ], "editorial": null, "rating": 1100, "tags": [ "constructive algorithms", "greedy" ], "testset_size": 15, "official_tests": [ { "input": "7\r\n5\r\n1 3 5 7 9\r\n4\r\n4 4 4 4\r\n3\r\n2 3 4\r\n4\r\n3 2 2 8\r\n6\r\n4 3 6 1 2 1\r\n6\r\n3 6 1 2 1 2\r\n5\r\n999999996 999999997 999999998 999999999 1000000000\r\n", "output": "0\r\n0\r\n2\r\n4\r\n3\r\n3\r\n3\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2041/B", "aliases": null, "contest_id": "2041", "contest_name": "2024 ICPC Asia Taichung Regional Contest (Unrated, Online Mirror, ICPC Rules, Preferably Teams)", "contest_type": "ICPC", "contest_start": 1732431900, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 1024.0, "title": "Bowling Frame", "description": "Bowling is a national sport in Taiwan; everyone in the country plays the sport on a daily basis since their youth. Naturally, there are a lot of bowling alleys all over the country, and the competition between them is as intense as you can imagine.\n\nMaw-Shang owns one such bowling alley. To stand out from other competitors in the industry and draw attention from customers, he decided to hold a special event every month that features various unorthodox bowling rules. For the event this month, he came up with a new version of the game called X-pin bowling. In the traditional $$$10$$$-pin bowling game, a frame is built out of ten bowling pins forming a triangular shape of side length four. The pin closest to the player forms the first row, and the two pins behind it form the second row, and so on. Unlike the standard version, the game of $$$X$$$-pin bowling Maw-Shang designed allows a much larger number of pins that form a larger frame. The following figure shows a standard $$$10$$$-pin frame on the left, and on the right it shows a $$$21$$$-pin frame that forms a triangular shape of side length six which is allowed in the game of $$$X$$$-pin bowling.\n\nBeing the national sport, the government of Taiwan strictly regulates and standardizes the manufacturing of bowling pins. There are two types of bowling pins allowed, one in black and the other in white, and the bowling alley Maw-Shang owns has $$$w$$$ white pins and $$$b$$$ black pins. To make this new game exciting for the customers, Maw-Shang wants to build the largest possible frame from these $$$w+b$$$ pins. However, even though he is okay with using both colors in building the frame, for aesthetic reasons, Maw-Shang still wants the colors of the pins on the same row to be identical. For example, the following figure shows two possible frames of side length six, but only the left one is acceptable to Maw-Shang since the other one has white and black pins mixed in the third row.\n\nThe monthly special event is happening in just a few hours. Please help Maw-Shang calculate the side length of the largest frame that he can build from his $$$w+b$$$ pins!", "input_format": "The first line of the input contains a single integer $$$t$$$, the number of test cases. Each of the following $$$t$$$ lines contains two integers $$$w$$$ and $$$b$$$, the number of white and black pins, respectively.\n\n- $$$1 \\leq t \\leq 100$$$\n- $$$0 \\leq w, b \\leq 10^9$$$", "output_format": "For each test case, output in a single line the side length $$$k$$$ of the largest pin satisfying Maw-Shang's requirement you can build with the given pins.", "interaction_format": null, "note": null, "examples": [ { "input": "4\n1 2\n3 2\n3 3\n12 0", "output": "2\n2\n3\n4" } ], "editorial": null, "rating": 1200, "tags": [ "binary search", "brute force", "math" ], "testset_size": 9, "official_tests": [ { "input": "4\r\n1 2\r\n3 2\r\n3 3\r\n12 0\r\n", "output": "2\r\n2\r\n3\r\n4\r\n" }, { "input": "100\r\n0 0\r\n0 1\r\n0 2\r\n0 3\r\n0 4\r\n0 5\r\n0 6\r\n0 7\r\n0 8\r\n0 9\r\n1 0\r\n1 1\r\n1 2\r\n1 3\r\n1 4\r\n1 5\r\n1 6\r\n1 7\r\n1 8\r\n1 9\r\n2 0\r\n2 1\r\n2 2\r\n2 3\r\n2 4\r\n2 5\r\n2 6\r\n2 7\r\n2 8\r\n2 9\r\n3 0\r\n3 1\r\n3 2\r\n3 3\r\n3 4\r\n3 5\r\n3 6\r\n3 7\r\n3 8\r\n3 9\r\n4 0\r\n4 1\r\n4 2\r\n4 3\r\n4 4\r\n4 5\r\n4 6\r\n4 7\r\n4 8\r\n4 9\r\n5 0\r\n5 1\r\n5 2\r\n5 3\r\n5 4\r\n5 5\r\n5 6\r\n5 7\r\n5 8\r\n5 9\r\n6 0\r\n6 1\r\n6 2\r\n6 3\r\n6 4\r\n6 5\r\n6 6\r\n6 7\r\n6 8\r\n6 9\r\n7 0\r\n7 1\r\n7 2\r\n7 3\r\n7 4\r\n7 5\r\n7 6\r\n7 7\r\n7 8\r\n7 9\r\n8 0\r\n8 1\r\n8 2\r\n8 3\r\n8 4\r\n8 5\r\n8 6\r\n8 7\r\n8 8\r\n8 9\r\n9 0\r\n9 1\r\n9 2\r\n9 3\r\n9 4\r\n9 5\r\n9 6\r\n9 7\r\n9 8\r\n9 9\r\n", "output": "0\r\n1\r\n1\r\n2\r\n2\r\n2\r\n3\r\n3\r\n3\r\n3\r\n1\r\n1\r\n2\r\n2\r\n2\r\n3\r\n3\r\n3\r\n3\r\n4\r\n1\r\n2\r\n2\r\n2\r\n3\r\n3\r\n3\r\n3\r\n4\r\n4\r\n2\r\n2\r\n2\r\n3\r\n3\r\n3\r\n3\r\n4\r\n4\r\n4\r\n2\r\n2\r\n3\r\n3\r\n3\r\n3\r\n4\r\n4\r\n4\r\n4\r\n2\r\n3\r\n3\r\n3\r\n3\r\n4\r\n4\r\n4\r\n4\r\n4\r\n3\r\n3\r\n3\r\n3\r\n4\r\n4\r\n4\r\n4\r\n4\r\n5\r\n3\r\n3\r\n3\r\n4\r\n4\r\n4\r\n4\r\n4\r\n5\r\n5\r\n3\r\n3\r\n4\r\n4\r\n4\r\n4\r\n4\r\n5\r\n5\r\n5\r\n3\r\n4\r\n4\r\n4\r\n4\r\n4\r\n5\r\n5\r\n5\r\n5\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2041/E", "aliases": null, "contest_id": "2041", "contest_name": "2024 ICPC Asia Taichung Regional Contest (Unrated, Online Mirror, ICPC Rules, Preferably Teams)", "contest_type": "ICPC", "contest_start": 1732431900, "contest_start_year": 2024, "index": "E", "time_limit": 1.0, "memory_limit": 1024.0, "title": "Beautiful Array", "description": "Image generated by ChatGPT 4o.\n\nA-Ming's birthday is coming and his friend A-May decided to give him an integer array as a present. A-Ming has two favorite numbers $$$a$$$ and $$$b$$$, and he thinks an array is beautiful if its mean is exactly $$$a$$$ and its median is exactly $$$b$$$. Please help A-May find a beautiful array so her gift can impress A-Ming.\n\nThe mean of an array is its sum divided by its length. For example, the mean of array $$$[3, -1, 5, 5]$$$ is $$$12 \\div 4 = 3$$$.\n\nThe median of an array is its middle element after sorting if its length is odd, or the mean of two middle elements after sorting if its length is even. For example, the median of $$$[1, 1, 2, 4, 8]$$$ is $$$2$$$ and the median of $$$[3, -1, 5, 5]$$$ is $$$(3 + 5) \\div 2 = 4$$$.\n\nNote that the mean and median are not rounded to an integer. For example, the mean of array $$$[1, 2]$$$ is $$$1.5$$$.", "input_format": "The only line contains two integers $$$a$$$ and $$$b$$$.\n\n- $$$-100 \\leq a, b \\leq 100$$$.\n- The length of the array must be between $$$1$$$ and $$$1000$$$.\n- The elements of the array must be integers and their absolute values must not exceed $$$10^6$$$.", "output_format": "In the first line, print the length of the array.\n\nIn the second line, print the elements of the array.\n\nIf there are multiple solutions, you can print any. It can be proved that, under the constraints of the problem, a solution always exists.", "interaction_format": null, "note": null, "examples": [ { "input": "3 4", "output": "4\n3 -1 5 5" }, { "input": "-100 -100", "output": "1\n-100" } ], "editorial": null, "rating": 1200, "tags": [ "constructive algorithms", "math" ], "testset_size": 12, "official_tests": [ { "input": "3 4\r\n", "output": "3\r\n4 4 1\r\n" }, { "input": "-100 -100\r\n", "output": "3\r\n-100 -100 -100\r\n" }, { "input": "0 0\r\n", "output": "3\r\n0 0 0\r\n" }, { "input": "100 -100\r\n", "output": "3\r\n-100 -100 500\r\n" }, { "input": "-100 100\r\n", "output": "3\r\n100 100 -500\r\n" }, { "input": "100 100\r\n", "output": "3\r\n100 100 100\r\n" }, { "input": "-94 87\r\n", "output": "3\r\n87 87 -456\r\n" }, { "input": "-69 -42\r\n", "output": "3\r\n-42 -42 -123\r\n" }, { "input": "0 -99\r\n", "output": "3\r\n-99 -99 198\r\n" }, { "input": "100 -99\r\n", "output": "3\r\n-99 -99 498\r\n" }, { "input": "3 28\r\n", "output": "3\r\n28 28 -47\r\n" }, { "input": "28 3\r\n", "output": "3\r\n3 3 78\r\n" } ], "official_tests_complete": true, "input_mode": "stdio", "generated_checker": null, "executable": false }, { "id": "2027/B", "aliases": null, "contest_id": "2027", "contest_name": "Codeforces Round 982 (Div. 2)", "contest_type": "CF", "contest_start": 1729953300, "contest_start_year": 2024, "index": "B", "time_limit": 1.0, "memory_limit": 256.0, "title": "Stalin Sort", "description": "Stalin Sort is a humorous sorting algorithm designed to eliminate elements which are out of place instead of bothering to sort them properly, lending itself to an $$$\\mathcal{O}(n)$$$ time complexity.\n\nIt goes as follows: starting from the second element in the array, if it is strictly smaller than the previous element (ignoring those which have already been deleted), then delete it. Continue iterating through the array until it is sorted in non-decreasing order. For example, the array $$$[1, 4, 2, 3, 6, 5, 5, 7, 7]$$$ becomes $$$[1, 4, 6, 7, 7]$$$ after a Stalin Sort.\n\nWe define an array as vulnerable if you can sort it in non-increasing order by repeatedly applying a Stalin Sort to any of its subarrays$$$^{\\text{∗}}$$$, as many times as is needed.\n\nGiven an array $$$a$$$ of $$$n$$$ integers, determine the minimum number of integers which must be removed from the array to make it vulnerable.", "input_format": "Each test consists of several test cases. The first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 500$$$) — the number of test cases. This is followed by descriptions of the test cases.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$1 \\le n \\le 2000$$$) — the size of the array.\n\nThe second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 10^9$$$).\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.", "output_format": "For each test case, output a single integer — the minimum number of integers which must be removed from the array to make it vulnerable.", "interaction_format": null, "note": "In the first test case, the optimal answer is to remove the numbers $$$3$$$ and $$$9$$$. Then we are left with $$$a = [6, 4, 2, 5, 2]$$$. To show this array is vulnerable, we can first apply a Stalin Sort on the subarray $$$[4, 2, 5]$$$ to get $$$a = [6, 4, 5, 2]$$$ and then apply a Stalin Sort on the subarray $$$[6, 4, 5]$$$ to get $$$a = [6, 2]$$$, which is non-increasing.\n\nIn the second test case, the array is already non-increasing, so we don't have to remove any integers.", "examples": [ { "input": "6\n7\n3 6 4 9 2 5 2\n5\n5 4 4 2 2\n8\n2 2 4 4 6 6 10 10\n1\n1000\n9\n6 8 9 10 12 9 7 5 4\n7\n300000000 600000000 400000000 900000000 200000000 400000000 200000000", "output": "2\n0\n6\n0\n4\n2" } ], "editorial": "An array is vulnerable if and only if the first element is the largest. To prove the forward direction, we can trivially perform a single operation on the entire range, which will clearly make it non-increasing. Now, let's prove the reverse direction. Consider any array in which the maximum is not the first element. Note that a Stalin Sort on any subarray will never remove the first element, and also will never remove the maximum. So if the first is not the maximum, this will always break the non-increasing property.\nTherefore, we just need to find the longest subsequence in which the first element is the largest. This can be done easily in $$$\\mathcal{O}(n^2)$$$ — consider each index being the first item in the subsequence, and count all items to the right of it which are smaller or equal to it. Find the maximum over all of these, then subtract this from $$$n$$$.\nBonus: Solve this task in $$$\\mathcal{O}(n \\log n)$$$.", "rating": 1100, "tags": [ "brute force", "greedy" ], "testset_size": 10, "official_tests": [ { "input": "6\r\n7\r\n3 6 4 9 2 5 2\r\n5\r\n5 4 4 2 2\r\n8\r\n2 2 4 4 6 6 10 10\r\n1\r\n1000\r\n9\r\n6 8 9 10 12 9 7 5 4\r\n7\r\n300000000 600000000 400000000 900000000 200000000 400000000 200000000\r\n", "output": "2\r\n0\r\n6\r\n0\r\n4\r\n2\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2060/D", "aliases": null, "contest_id": "2060", "contest_name": "Codeforces Round 998 (Div. 3)", "contest_type": "ICPC", "contest_start": 1737297300, "contest_start_year": 2025, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Subtract Min Sort", "description": "You are given a sequence $$$a$$$ consisting of $$$n$$$ positive integers.\n\nYou can perform the following operation any number of times.\n\n- Select an index $$$i$$$ ($$$1 \\le i < n$$$), and subtract $$$\\min(a_i,a_{i+1})$$$ from both $$$a_i$$$ and $$$a_{i+1}$$$.\n\nDetermine if it is possible to make the sequence non-decreasing by using the operation any number of times.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$).\n\nThe second line of each test case contains $$$a_1,a_2,\\ldots,a_n$$$ ($$$1 \\le a_i \\le 10^9$$$).\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "If it is possible to make the sequence non-decreasing, print \"YES\" on a new line. Otherwise, print \"NO\" on a new line.\n\nYou can output the answer in any case. For example, the strings \"yEs\", \"yes\", and \"Yes\" will also be recognized as positive responses.", "interaction_format": null, "note": "In the first test case, the array is already sorted.\n\nIn the second test case, we can show that it is impossible.\n\nIn the third test case, after performing an operation on $$$i=1$$$, the array becomes $$$[0,1,2,3]$$$, which is now in nondecreasing order.", "examples": [ { "input": "5\n5\n1 2 3 4 5\n4\n4 3 2 1\n4\n4 5 2 3\n8\n4 5 4 5 4 5 4 5\n9\n9 9 8 2 4 4 3 5 3", "output": "YES\nNO\nYES\nYES\nNO" } ], "editorial": null, "rating": 1100, "tags": [ "greedy" ], "testset_size": 21, "official_tests": [ { "input": "5\r\n5\r\n1 2 3 4 5\r\n4\r\n4 3 2 1\r\n4\r\n4 5 2 3\r\n8\r\n4 5 4 5 4 5 4 5\r\n9\r\n9 9 8 2 4 4 3 5 3\r\n", "output": "YES\r\nNO\r\nYES\r\nYES\r\nNO\r\n" }, { "input": "1\r\n3\r\n1 1 2\r\n", "output": "YES\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2051/D", "aliases": null, "contest_id": "2051", "contest_name": "Codeforces Round 995 (Div. 3)", "contest_type": "ICPC", "contest_start": 1734878100, "contest_start_year": 2024, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Counting Pairs", "description": "You are given a sequence $$$a$$$, consisting of $$$n$$$ integers, where the $$$i$$$-th element of the sequence is equal to $$$a_i$$$. You are also given two integers $$$x$$$ and $$$y$$$ ($$$x \\le y$$$).\n\nA pair of integers $$$(i, j)$$$ is considered interesting if the following conditions are met:\n\n- $$$1 \\le i < j \\le n$$$;\n- if you simultaneously remove the elements at positions $$$i$$$ and $$$j$$$ from the sequence $$$a$$$, the sum of the remaining elements is at least $$$x$$$ and at most $$$y$$$.\n\nYour task is to determine the number of interesting pairs of integers for the given sequence $$$a$$$.", "input_format": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases.\n\nEach test case consists of two lines:\n\n- The first line contains three integers $$$n, x, y$$$ ($$$3 \\le n \\le 2 \\cdot 10^5$$$, $$$1 \\le x \\le y \\le 2 \\cdot 10^{14}$$$);\n- The second line contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 10^{9}$$$).\n\nAdditional constraint on the input: the sum of $$$n$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output one integer — the number of interesting pairs of integers for the given sequence $$$a$$$.", "interaction_format": null, "note": "In the first example, there are $$$4$$$ interesting pairs of integers:\n\n1. $$$(1, 2)$$$;\n2. $$$(1, 4)$$$;\n3. $$$(2, 3)$$$;\n4. $$$(3, 4)$$$.", "examples": [ { "input": "7\n4 8 10\n4 6 3 6\n6 22 27\n4 9 6 3 4 5\n3 8 10\n3 2 1\n3 1 1\n2 3 4\n3 3 6\n3 2 1\n4 4 12\n3 3 2 1\n6 8 8\n1 1 2 2 2 3", "output": "4\n7\n0\n0\n1\n5\n6" } ], "editorial": "There is a common trick in problems of the form \"count something on segment $$$[l, r]$$$\": calculate the answer for $$$[0, r]$$$, and then subtract the answer for $$$[0, l-1]$$$. We can use this trick in our problem as follows: calculate the number of pairs $$$i,j$$$ such that the sum of all other elements is less than $$$y+1$$$, and subtract the number of pairs such that the sum is less than $$$x$$$.\nNow we need to solve the following problem: given an array and an integer $$$x$$$, calculate the number of ways to choose $$$i,j$$$ ($$$1 \\le i < j \\le n$$$) so that the sum of all elements, except for $$$a_i$$$ and $$$a_j$$$, is less than $$$x$$$.\nNaive solution (iterate on the pair, calculate the sum of remaining elements) works in $$$O(n^3)$$$. It can be improved to $$$O(n^2)$$$ if, instead of calculating the sum of remaining elements in $$$O(n)$$$, we do it in $$$O(1)$$$: if we remove $$$a_i$$$ and $$$a_j$$$, the remaining elements sum up to $$$s - a_i - a_j$$$, where $$$s$$$ is the sum of all elements.\nHowever, $$$O(n^2)$$$ is still too slow. For every $$$i$$$, let's try to calculate the number of elements $$$j$$$ which \"match\" it faster. If we sort the array, the answer won't change; but in a sorted array, for every $$$i$$$, all possible values of $$$j$$$ form a suffix of the array (if $$$s - a_i - a_j < x$$$ and $$$a_{j+1} \\ge a_j$$$, then $$$s - a_i - a_{j+1} < x$$$).\nSo, for every $$$i$$$, let's find the minimum $$$j'$$$ such that $$$s - a_i - a_{j'} < x$$$; all $$$j \\ge j'$$$ are possible \"matches\" for $$$i$$$. This can be done with two pointers method: when we decrease $$$i$$$, the index $$$j'$$$ won't decrease.\nUnfortunately, this method has an issue. We need to calculate only pairs where $$$ij$$$. For every such pair, there is a pair with $$$i 1$$$, we see that $$$k = 1$$$ and $$$k = n$$$ cannot yield a satisfactory construction. Proof is as follows:\n• $$$m = 1$$$ will yield $$$ans = \\lfloor \\frac{n+1}{2} \\rfloor$$$, which will never be equal to $$$1$$$ or $$$n$$$ when $$$n \\ge 3$$$.\n• If $$$m > 1$$$, considering the case of $$$k = 1$$$, we see that $$$\\operatorname{median}(b_i) = 1$$$ iff $$$i \\ge 2$$$, and since the original array $$$a$$$ is an increasingly-sorted permutation, we can conclude that $$$\\operatorname{median}(b_1) < 1$$$. This is not possible.\n• Similarly, $$$k = n$$$ also doesn't work with $$$m > 1$$$, as it'll require $$$\\operatorname{median}(b_m) > n$$$.\nApart from these cases, any other $$$k$$$ can yield an answer with $$$m = 3$$$  — a prefix subarray $$$b_1$$$, a middle subarray $$$b_2$$$ containing $$$k$$$ ($$$b_2$$$ will be centered at $$$k$$$, of course), and a suffix subarray $$$b_3$$$. This way, the answer will be $$$\\operatorname{median}(b_2) = k$$$.\nThe length of $$$b_2$$$ can be either $$$1$$$ or $$$3$$$, depending on the parity of $$$k$$$ (so that $$$b_1$$$ and $$$b_3$$$ could have odd lengths). In detail: $$$b_2$$$ will have length $$$1$$$ (i.e., $$$[k]$$$) if $$$k$$$ is an even integer, and length $$$3$$$ (i.e., $$$[k-1, k, k+1]$$$) if $$$k$$$ is an odd integer.\nTime complexity: $$$\\mathcal{O}(1)$$$.", "rating": 1100, "tags": [ "constructive algorithms", "greedy", "implementation", "math" ], "testset_size": 10, "official_tests": [ { "input": "4\r\n1 1\r\n3 2\r\n3 3\r\n15 8\r\n", "output": "1\r\n1\r\n3\r\n1 2 3\r\n-1\r\n3\r\n1 8 9\r\n" }, { "input": "2\r\n199999 199999\r\n1 1\r\n", "output": "-1\r\n1\r\n1\r\n" }, { "input": "2\r\n1 1\r\n199999 1\r\n", "output": "1\r\n1\r\n-1\r\n" }, { "input": "1\r\n199999 62226\r\n", "output": "3\r\n1 62226 62227\r\n" }, { "input": "2\r\n3 1\r\n199997 108263\r\n", "output": "-1\r\n3\r\n1 108262 108265\r\n" }, { "input": "10\r\n9999 1\r\n9999 9999\r\n15673 1\r\n38721 38721\r\n89211 1\r\n30183 30183\r\n5023 1\r\n1023 1023\r\n111 1\r\n57 57\r\n", "output": "-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n" }, { "input": "10\r\n57 1\r\n111 111\r\n1023 1\r\n5023 5023\r\n30183 1\r\n89211 89211\r\n38721 1\r\n15673 15673\r\n9999 1\r\n9999 9999\r\n", "output": "-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n-1\r\n" }, { "input": "1\r\n199999 199998\r\n", "output": "3\r\n1 199998 199999\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": false }, { "id": "2003/C", "aliases": null, "contest_id": "2003", "contest_name": "Codeforces Round 968 (Div. 2)", "contest_type": "CF", "contest_start": 1724596500, "contest_start_year": 2024, "index": "C", "time_limit": 2.0, "memory_limit": 256.0, "title": "Turtle and Good Pairs", "description": "Turtle gives you a string $$$s$$$, consisting of lowercase Latin letters.\n\nTurtle considers a pair of integers $$$(i, j)$$$ ($$$1 \\le i < j \\le n$$$) to be a pleasant pair if and only if there exists an integer $$$k$$$ such that $$$i \\le k < j$$$ and both of the following two conditions hold:\n\n- $$$s_k \\ne s_{k + 1}$$$;\n- $$$s_k \\ne s_i$$$ or $$$s_{k + 1} \\ne s_j$$$.\n\nBesides, Turtle considers a pair of integers $$$(i, j)$$$ ($$$1 \\le i < j \\le n$$$) to be a good pair if and only if $$$s_i = s_j$$$ or $$$(i, j)$$$ is a pleasant pair.\n\nTurtle wants to reorder the string $$$s$$$ so that the number of good pairs is maximized. Please help him!", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^4$$$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$) — the length of the string.\n\nThe second line of each test case contains a string $$$s$$$ of length $$$n$$$, consisting of lowercase Latin letters.\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output the string $$$s$$$ after reordering so that the number of good pairs is maximized. If there are multiple answers, print any of them.", "interaction_format": null, "note": "In the first test case, $$$(1, 3)$$$ is a good pair in the reordered string. It can be seen that we can't reorder the string so that the number of good pairs is greater than $$$1$$$. bac and cab can also be the answer.\n\nIn the second test case, $$$(1, 2)$$$, $$$(1, 4)$$$, $$$(1, 5)$$$, $$$(2, 4)$$$, $$$(2, 5)$$$, $$$(3, 5)$$$ are good pairs in the reordered string. efddd can also be the answer.", "examples": [ { "input": "5\n3\nabc\n5\nedddf\n6\nturtle\n8\npppppppp\n10\ncodeforces", "output": "acb\nddedf\nurtlet\npppppppp\ncodeforces" } ], "editorial": "Partition the string $$$s$$$ into several maximal contiguous segments of identical characters, denoted as $$$[l_1, r_1], [l_2, r_2], \\ldots, [l_m, r_m]$$$. For example, the string \"aabccc\" can be divided into $$$[1, 2], [3, 3], [4, 6]$$$.\nWe can observe that a pair $$$(i, j)$$$ is considered a \"good pair\" if and only if the segments containing $$$i$$$ and $$$j$$$ are non-adjacent.\nLet $$$a_i = r_i - l_i + 1$$$. Then, the number of good pairs is $$$\\frac{n(n - 1)}{2} - \\sum\\limits_{i = 1}^{m - 1} a_i \\cdot a_{i + 1}$$$. Hence, the task reduces to minimizing $$$\\sum\\limits_{i = 1}^{m - 1} a_i \\cdot a_{i + 1}$$$.\nIf $$$s$$$ consists of only one character, simply output the original string. Otherwise, for $$$m \\ge 2$$$, it can be inductively proven that $$$\\sum\\limits_{i = 1}^{m - 1} a_i \\cdot a_{i + 1} \\ge n - 1$$$, and this minimum value of $$$n - 1$$$ can be achieved.\nAs for the construction, let the maximum frequency of any character be $$$x$$$, and the second-highest frequency be $$$y$$$. Begin by placing $$$x - y$$$ instances of the most frequent character at the start. Then, there are $$$y$$$ remaining instances of both the most frequent and the second most frequent characters. Next, sort all characters by frequency in descending order and alternate between them when filling the positions (ignoring any character once it's fully used). This guarantees that, except for the initial segment of length $$$\\ge 1$$$, all other segments have a length of exactly $$$1$$$.\nTime complexity: $$$O(n + |\\Sigma| \\log |\\Sigma|)$$$ per test case, where $$$|\\Sigma| = 26$$$.", "rating": 1200, "tags": [ "constructive algorithms", "greedy", "sortings", "strings" ], "testset_size": 19, "official_tests": [ { "input": "5\r\n3\r\nabc\r\n5\r\nedddf\r\n6\r\nturtle\r\n8\r\npppppppp\r\n10\r\ncodeforces\r\n", "output": "cba\r\ndddfe\r\ntturle\r\npppppppp\r\noecsrfdoec\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": "import sys\nfrom collections import Counter\n\ndef read_file(path):\n with open(path, 'r') as f:\n lines = f.readlines()\n return [line.strip() for line in lines]\n\ndef main(input_path, output_path, submission_path):\n input_lines = read_file(input_path)\n submission_lines = read_file(submission_path)\n \n t = int(input_lines[0])\n ptr = 1\n sub_ptr = 0\n \n for _ in range(t):\n n = int(input_lines[ptr])\n s = input_lines[ptr + 1]\n ptr += 2\n \n if sub_ptr >= len(submission_lines):\n print(0)\n return\n t_sub = submission_lines[sub_ptr]\n sub_ptr += 1\n \n # Check permutation\n if len(t_sub) != n or Counter(t_sub) != Counter(s):\n print(0)\n return\n \n # Check all same case\n if len(set(s)) == 1:\n if t_sub != s:\n print(0)\n return\n continue\n \n # Compute sum of a_i * a_{i+1}\n segments = []\n current = t_sub[0]\n count = 1\n for c in t_sub[1:]:\n if c == current:\n count += 1\n else:\n segments.append(count)\n current = c\n count = 1\n segments.append(count)\n \n total_sum = 0\n for i in range(len(segments) - 1):\n total_sum += segments[i] * segments[i + 1]\n \n if total_sum != n - 1:\n print(0)\n return\n \n # Check all submission lines processed\n if sub_ptr != len(submission_lines):\n print(0)\n return\n \n print(1)\n\nif __name__ == \"__main__\":\n input_path = sys.argv[1]\n output_path = sys.argv[2]\n submission_path = sys.argv[3]\n main(input_path, output_path, submission_path)\n", "executable": true }, { "id": "2048/C", "aliases": null, "contest_id": "2048", "contest_name": "Codeforces Global Round 28", "contest_type": "CF", "contest_start": 1734618900, "contest_start_year": 2024, "index": "C", "time_limit": 2.0, "memory_limit": 256.0, "title": "Kevin and Binary Strings", "description": "Kevin discovered a binary string $$$s$$$ that starts with 1 in the river at Moonlit River Park and handed it over to you. Your task is to select two non-empty substrings$$$^{\\text{∗}}$$$ of $$$s$$$ (which can be overlapped) to maximize the XOR value of these two substrings.\n\nThe XOR of two binary strings $$$a$$$ and $$$b$$$ is defined as the result of the $$$\\oplus$$$ operation applied to the two numbers obtained by interpreting $$$a$$$ and $$$b$$$ as binary numbers, with the leftmost bit representing the highest value. Here, $$$\\oplus$$$ denotes the bitwise XOR operation.\n\nThe strings you choose may have leading zeros.", "input_format": "Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \\le t \\le 10^3$$$).\n\nThe only line of each test case contains a binary string $$$s$$$ that starts with 1 ($$$1\\le\\lvert s\\rvert\\le 5000$$$).\n\nIt is guaranteed that the sum of $$$\\lvert s\\rvert$$$ over all test cases doesn't exceed $$$5000$$$.", "output_format": "For each test case, output four integers $$$l_1, r_1, l_2, r_2$$$ ($$$1 \\le l_1 \\le r_1 \\le |s|$$$, $$$1 \\le l_2 \\le r_2 \\le |s|$$$) — in the case the two substrings you selected are $$$s_{l_1} s_{l_1 + 1} \\ldots s_{r_1}$$$ and $$$s_{l_2} s_{l_2 + 1} \\ldots s_{r_2}$$$.\n\nIf there are multiple solutions, print any of them.", "interaction_format": null, "note": "In the first test case, we can choose $$$ s_2=\\texttt{1} $$$ and $$$ s_1 s_2 s_3=\\texttt{111} $$$, and $$$ \\texttt{1}\\oplus\\texttt{111}=\\texttt{110} $$$. It can be proven that it is impossible to obtain a larger result. Additionally, $$$ l_1=3$$$, $$$r_1=3$$$, $$$l_2=1$$$, $$$r_2=3 $$$ is also a valid solution.\n\nIn the second test case, $$$ s_1 s_2 s_3=\\texttt{100} $$$, $$$ s_1 s_2 s_3 s_4=\\texttt{1000} $$$, the result is $$$ \\texttt{100}\\oplus\\texttt{1000}=\\texttt{1100} $$$, which is the maximum.", "examples": [ { "input": "5\n111\n1000\n10111\n11101\n1100010001101", "output": "2 2 1 3\n1 3 1 4\n1 5 1 4\n3 4 1 5\n1 13 1 11" } ], "editorial": "Hint #1: Is there a substring that must always be selected for all strings?\nHint #2: The substring $$$[1,n]$$$ must be selected. Can we determine the length of the other substring?\nHint #3: Pay special attention to the case where the entire string consists of only $$$1$$$s.\nTo maximize the XOR sum of the two substrings, we aim to maximize the number of binary digits in the XOR result. To achieve this, the substring $$$[1,n]$$$ must always be selected. Suppose the first character of the other substring is $$$1$$$. If it is not $$$1$$$, we can remove all leading zeros.\nNext, find the position of the first $$$0$$$ in the string from left to right. We want this position to be flipped to $$$1$$$, while ensuring that the $$$1$$$s earlier in the string are not changed to $$$0$$$s. Therefore, let the position of the first $$$0$$$ be $$$p$$$. The length of the other substring must be $$$n-p+1$$$. By enumerating the starting position of the other substring and calculating the XOR sum of the two substrings linearly, we can take the maximum value. The time complexity of this approach is $$$O(n^2)$$$.\nIf the entire string consists only of $$$1$$$s, selecting $$$[1,n]$$$ and $$$[1,1]$$$ can be proven to yield the maximum XOR sum among all possible choices.\nInteresting fact: This problem can actually be solved in $$$O(n)$$$ time complexity. Specifically, observe that the other substring needs to satisfy the following conditions: its length is $$$n-p+1$$$, and its first character is $$$1$$$. Thus, its starting position must be less than $$$p$$$. This implies that the length of the prefix of $$$1$$$s in the other substring can be chosen from the range $$$[1, p-1]$$$. We aim to flip the first segment of $$$0$$$s in the original string to $$$1$$$s, while ensuring that the $$$1$$$ immediately after this segment of $$$0$$$s remains unchanged. Let the length of the first segment of $$$0$$$s be $$$q$$$. Then, the length of the prefix of $$$1$$$s in the other substring must be $$$\\min(p-1, q)$$$, and the starting position can be determined efficiently.\nWhen preparing the contest and selecting problems, we determined that the $$$O(n)$$$ solution would be too difficult for a Problem C. Therefore, the problem was designed with an $$$O(n^2)$$$ data range to make it more accessible.", "rating": 1200, "tags": [ "bitmasks", "brute force", "greedy", "implementation", "strings" ], "testset_size": 22, "official_tests": [ { "input": "5\r\n111\r\n1000\r\n10111\r\n11101\r\n1100010001101\r\n", "output": "1 3 1 1\r\n1 4 1 3\r\n1 5 1 4\r\n1 5 3 4\r\n1 13 1 11\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": false }, { "id": "2065/C1", "aliases": null, "contest_id": "2065", "contest_name": "Codeforces Round 1003 (Div. 4)", "contest_type": "ICPC", "contest_start": 1739111700, "contest_start_year": 2025, "index": "C1", "time_limit": 2.0, "memory_limit": 256.0, "title": "Skibidus and Fanum Tax (easy version)", "description": "This is the easy version of the problem. In this version, $$$m = 1$$$.\n\nSkibidus has obtained two arrays $$$a$$$ and $$$b$$$, containing $$$n$$$ and $$$m$$$ elements respectively. For each integer $$$i$$$ from $$$1$$$ to $$$n$$$, he is allowed to perform the operation at most once:\n\n- Choose an integer $$$j$$$ such that $$$1 \\leq j \\leq m$$$. Set $$$a_i := b_j - a_i$$$. Note that $$$a_i$$$ may become non-positive as a result of this operation.\n\nSkibidus needs your help determining whether he can sort $$$a$$$ in non-decreasing order$$$^{\\text{∗}}$$$ by performing the above operation some number of times.", "input_format": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n \\leq 2 \\cdot 10^5$$$, $$$\\textbf{m = 1}$$$).\n\nThe following line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq 10^9$$$).\n\nThe following line of each test case contains $$$m$$$ integers $$$b_1, b_2, \\ldots, b_m$$$ ($$$1 \\leq b_i \\leq 10^9$$$).\n\nIt is guaranteed that the sum of $$$n$$$ and the sum of $$$m$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, if it is possible to sort $$$a$$$ in non-decreasing order, print \"YES\" on a new line. Otherwise, print \"NO\" on a new line.\n\nYou can output the answer in any case. For example, the strings \"yEs\", \"yes\", and \"Yes\" will also be recognized as positive responses.", "interaction_format": null, "note": "In the first test case, $$$[5]$$$ is already sorted.\n\nIn the second test case, it can be shown that it is impossible.\n\nIn the third test case, we can set $$$a_3:=b_1-a_3=6-2=4$$$. The sequence $$$[1,4,4,5]$$$ is in nondecreasing order.\n\nIn the last case, we can apply operations on each index. The sequence becomes $$$[-1,0,1]$$$, which is in nondecreasing order.", "examples": [ { "input": "5\n1 1\n5\n9\n3 1\n1 4 3\n3\n4 1\n1 4 2 5\n6\n4 1\n5 4 10 5\n4\n3 1\n9 8 7\n8", "output": "YES\nNO\nYES\nNO\nYES" } ], "editorial": null, "rating": 1100, "tags": [ "binary search", "dp", "greedy" ], "testset_size": 7, "official_tests": [ { "input": "5\r\n1 1\r\n5\r\n9\r\n3 1\r\n1 4 3\r\n3\r\n4 1\r\n1 4 2 5\r\n6\r\n4 1\r\n5 4 10 5\r\n4\r\n3 1\r\n9 8 7\r\n8\r\n", "output": "YES\r\nNO\r\nYES\r\nNO\r\nYES\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2065/D", "aliases": null, "contest_id": "2065", "contest_name": "Codeforces Round 1003 (Div. 4)", "contest_type": "ICPC", "contest_start": 1739111700, "contest_start_year": 2025, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Skibidus and Sigma", "description": "Let's denote the score of an array $$$b$$$ with $$$k$$$ elements as $$$\\sum_{i=1}^{k}\\left(\\sum_{j=1}^ib_j\\right)$$$. In other words, let $$$S_i$$$ denote the sum of the first $$$i$$$ elements of $$$b$$$. Then, the score can be denoted as $$$S_1+S_2+\\ldots+S_k$$$.\n\nSkibidus is given $$$n$$$ arrays $$$a_1,a_2,\\ldots,a_n$$$, each of which contains $$$m$$$ elements. Being the sigma that he is, he would like to concatenate them in any order to form a single array containing $$$n\\cdot m$$$ elements. Please find the maximum possible score Skibidus can achieve with his concatenated array!\n\nFormally, among all possible permutations$$$^{\\text{∗}}$$$ $$$p$$$ of length $$$n$$$, output the maximum score of $$$a_{p_1} + a_{p_2} + \\dots + a_{p_n}$$$, where $$$+$$$ represents concatenation$$$^{\\text{†}}$$$.", "input_format": "The first line contains an integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n \\cdot m \\leq 2 \\cdot 10^5$$$) — the number of arrays and the length of each array.\n\nThe $$$i$$$'th of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i,1}, a_{i,2}, \\ldots, a_{i,m}$$$ ($$$1 \\leq a_{i,j} \\leq 10^6$$$) — the elements of the $$$i$$$'th array.\n\nIt is guaranteed that the sum of $$$n \\cdot m$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output the maximum score among all possible permutations $$$p$$$ on a new line.", "interaction_format": null, "note": "For the first test case, there are two possibilities for $$$p$$$:\n\n- $$$p = [1, 2]$$$. Then, $$$a_{p_1} + a_{p_2} = [4, 4, 6, 1]$$$. Its score is $$$4+(4+4)+(4+4+6)+(4+4+6+1)=41$$$.\n- $$$p = [2, 1]$$$. Then, $$$a_{p_1} + a_{p_2} = [6, 1, 4, 4]$$$. Its score is $$$6+(6+1)+(6+1+4)+(6+1+4+4)=39$$$.\n\nThe maximum possible score is $$$41$$$.\n\nIn the second test case, one optimal arrangement of the final concatenated array is $$$[4,1,2,1,2,2,2,2,3,2,1,2]$$$. We can calculate that the score is $$$162$$$.", "examples": [ { "input": "3\n2 2\n4 4\n6 1\n3 4\n2 2 2 2\n3 2 1 2\n4 1 2 1\n2 3\n3 4 5\n1 1 9", "output": "41\n162\n72" } ], "editorial": null, "rating": 1200, "tags": [ "greedy", "sortings" ], "testset_size": 12, "official_tests": [ { "input": "3\r\n2 2\r\n4 4\r\n6 1\r\n3 4\r\n2 2 2 2\r\n3 2 1 2\r\n4 1 2 1\r\n2 3\r\n3 4 5\r\n1 1 9\r\n", "output": "41\r\n162\r\n72\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2036/C", "aliases": null, "contest_id": "2036", "contest_name": "Codeforces Round 984 (Div. 3)", "contest_type": "ICPC", "contest_start": 1730558100, "contest_start_year": 2024, "index": "C", "time_limit": 3.0, "memory_limit": 256.0, "title": "Anya and 1100", "description": "While rummaging through things in a distant drawer, Anya found a beautiful string $$$s$$$ consisting only of zeros and ones.\n\nNow she wants to make it even more beautiful by performing $$$q$$$ operations on it.\n\nEach operation is described by two integers $$$i$$$ ($$$1 \\le i \\le |s|$$$) and $$$v$$$ ($$$v \\in \\{0, 1\\}$$$) and means that the $$$i$$$-th character of the string is assigned the value $$$v$$$ (that is, the assignment $$$s_i = v$$$ is performed).\n\nBut Anya loves the number $$$1100$$$, so after each query, she asks you to tell her whether the substring \"1100\" is present in her string (i.e. there exist such $$$1 \\le i \\le |s| - 3$$$ that $$$s_{i}s_{i + 1}s_{i + 2}s_{i + 3} = \\texttt{1100}$$$).", "input_format": "The first line contains one integer $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases.\n\nThe first line of the test case contains the string $$$s$$$ ($$$1 \\leq |s| \\leq 2 \\cdot 10^5$$$), consisting only of the characters \"0\" and \"1\". Here $$$|s|$$$ denotes the length of the string $$$s$$$.\n\nThe next line contains an integer $$$q$$$ ($$$1 \\leq q \\leq 2 \\cdot 10^5$$$) — the number of queries.\n\nThe following $$$q$$$ lines contain two integers $$$i$$$ ($$$1 \\leq i \\leq |s|$$$) and $$$v$$$ ($$$v \\in \\{0, 1\\}$$$), describing the query.\n\nIt is guaranteed that the sum of $$$|s|$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$. It is also guaranteed that the sum of $$$q$$$ across all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each query, output \"YES\", if \"1100\" is present in Anya's string; otherwise, output \"NO\".\n\nYou can output the answer in any case (upper or lower). For example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as positive responses.", "interaction_format": null, "note": null, "examples": [ { "input": "4\n100\n4\n1 1\n2 0\n2 0\n3 1\n1100000\n3\n6 1\n7 1\n4 1\n111010\n4\n1 1\n5 0\n4 1\n5 0\n0100\n4\n3 1\n1 1\n2 0\n2 1", "output": "NO\nNO\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO" } ], "editorial": "Firstly, in a naive way, let's calculate $$$count$$$ — the number of occurrences of $$$1100$$$ in $$$s$$$.\nAfter that, for each of the $$$q$$$ queries, we will update $$$count$$$: let's look at the substring $$$s[max(1, i - 3); i]$$$ before changing $$$s_i$$$ and find $$$before$$$ — the number of occurrences of $$$1100$$$ in it. After that, we update $$$s_i = v$$$ and similarly find $$$after$$$ — the number of occurrences of $$$1100$$$ in $$$s[max(1, i - 3); i]$$$ after applying the query.\nThus, by applying $$$count = count + (after - before)$$$, we will get the number of occurrences of $$$1100$$$ in $$$s$$$ after applying the query. If $$$count > 0$$$, the response to the request is — \"YES\", otherwise — \"NO\".", "rating": 1100, "tags": [ "brute force", "implementation" ], "testset_size": 61, "official_tests": [ { "input": "4\r\n100\r\n4\r\n1 1\r\n2 0\r\n2 0\r\n3 1\r\n1100000\r\n3\r\n6 1\r\n7 1\r\n4 1\r\n111010\r\n4\r\n1 1\r\n5 0\r\n4 1\r\n5 0\r\n0100\r\n4\r\n3 1\r\n1 1\r\n2 0\r\n2 1\r\n", "output": "NO\r\nNO\r\nNO\r\nNO\r\nYES\r\nYES\r\nNO\r\nNO\r\nYES\r\nYES\r\nYES\r\nNO\r\nNO\r\nNO\r\nNO\r\n" }, { "input": "1\r\n010\r\n1\r\n1 1\r\n", "output": "NO\r\n" }, { "input": "1\r\n11000000000000000000\r\n1\r\n20 1\r\n", "output": "YES\r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": true }, { "id": "2044/D", "aliases": null, "contest_id": "2044", "contest_name": "Codeforces Round 993 (Div. 4)", "contest_type": "ICPC", "contest_start": 1734273300, "contest_start_year": 2024, "index": "D", "time_limit": 2.0, "memory_limit": 256.0, "title": "Harder Problem", "description": "Given a sequence of positive integers, a positive integer is called a mode of the sequence if it occurs the maximum number of times that any positive integer occurs. For example, the mode of $$$[2,2,3]$$$ is $$$2$$$. Any of $$$9$$$, $$$8$$$, or $$$7$$$ can be considered to be a mode of the sequence $$$[9,9,8,8,7,7]$$$.\n\nYou gave UFO an array $$$a$$$ of length $$$n$$$. To thank you, UFO decides to construct another array $$$b$$$ of length $$$n$$$ such that $$$a_i$$$ is a mode of the sequence $$$[b_1, b_2, \\ldots, b_i]$$$ for all $$$1 \\leq i \\leq n$$$.\n\nHowever, UFO doesn't know how to construct array $$$b$$$, so you must help her. Note that $$$1 \\leq b_i \\leq n$$$ must hold for your array for all $$$1 \\leq i \\leq n$$$.", "input_format": "The first line contains $$$t$$$ ($$$1 \\leq t \\leq 10^4$$$) — the number of test cases.\n\nThe first line of each test case contains an integer $$$n$$$ ($$$1 \\leq n \\leq 2 \\cdot 10^5$$$) — the length of $$$a$$$.\n\nThe following line of each test case contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\leq a_i \\leq n$$$).\n\nIt is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.", "output_format": "For each test case, output $$$n$$$ numbers $$$b_1, b_2, \\ldots, b_n$$$ ($$$1 \\leq b_i \\leq n$$$) on a new line. It can be shown that $$$b$$$ can always be constructed. If there are multiple possible arrays, you may print any.", "interaction_format": null, "note": "Let's verify the correctness for our sample output in test case $$$2$$$.\n\n- At $$$i = 1$$$, $$$1$$$ is the only possible mode of $$$[1]$$$.\n- At $$$i = 2$$$, $$$1$$$ is the only possible mode of $$$[1, 1]$$$.\n- At $$$i = 3$$$, $$$1$$$ is the only possible mode of $$$[1, 1, 2]$$$.\n- At $$$i = 4$$$, $$$1$$$ or $$$2$$$ are both modes of $$$[1, 1, 2, 2]$$$. Since $$$a_i = 2$$$, this array is valid.", "examples": [ { "input": "4\n2\n1 2\n4\n1 1 1 2\n8\n4 5 5 5 1 1 2 1\n10\n1 1 2 2 1 1 3 3 1 1", "output": "1 2\n1 1 2 2\n4 5 5 1 1 2 2 3\n1 8 2 2 1 3 3 9 1 1" } ], "editorial": null, "rating": 1100, "tags": [ "constructive algorithms", "greedy", "math" ], "testset_size": 19, "official_tests": [ { "input": "4\r\n2\r\n1 2\r\n4\r\n1 1 1 2\r\n8\r\n4 5 5 5 1 1 2 1\r\n10\r\n1 1 2 2 1 1 3 3 1 1\r\n", "output": "1 2 \r\n1 2 3 4 \r\n4 5 1 2 3 6 7 8 \r\n1 2 3 4 5 6 7 8 9 10 \r\n" }, { "input": "32\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n5\r\n5 1 1 1 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n5\r\n5 1 1 1 1\r\n5\r\n5 1 1 1 2\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n5\r\n5 1 1 1 1\r\n5\r\n5 1 1 1 2\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n5\r\n5 1 1 1 1\r\n5\r\n5 1 1 1 2\r\n2\r\n2 2\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n5\r\n5 1 1 1 1\r\n5\r\n5 1 1 1 2\r\n3\r\n3 3 3\r\n", "output": "1 \r\n1 \r\n1 \r\n1 \r\n5 1 2 3 4 \r\n1 \r\n1 \r\n1 \r\n1 \r\n5 1 2 3 4 \r\n5 1 2 3 4 \r\n1 \r\n1 \r\n1 \r\n1 \r\n5 1 2 3 4 \r\n5 1 2 3 4 \r\n1 \r\n1 \r\n1 \r\n1 \r\n1 \r\n5 1 2 3 4 \r\n5 1 2 3 4 \r\n2 1 \r\n1 \r\n1 \r\n1 \r\n1 \r\n5 1 2 3 4 \r\n5 1 2 3 4 \r\n3 1 2 \r\n" } ], "official_tests_complete": false, "input_mode": "stdio", "generated_checker": null, "executable": false } ]