{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eThis is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\u003cp\u003eAlice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $$$n$$$ stations, enumerated from $$$1$$$ through $$$n$$$. The train occupies one station at a time and travels around the network of stations in a circular manner. More precisely, the immediate station that the train will visit after station $$$i$$$ is station $$$i+1$$$ if $$$1 \\leq i \u0026lt; n$$$ or station $$$1$$$ if $$$i \u003d n$$$. It takes the train $$$1$$$ second to travel to its next station as described.\u003c/p\u003e\u003cp\u003eBob gave Alice a fun task before he left: to deliver $$$m$$$ candies that are initially at some stations to their independent destinations using the train. The candies are enumerated from $$$1$$$ through $$$m$$$. Candy $$$i$$$ ($$$1 \\leq i \\leq m$$$), now at station $$$a_i$$$, should be delivered to station $$$b_i$$$ ($$$a_i \\neq b_i$$$).\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/bd1ed13f45782fe70dea4df2c2718d49?v\u003d1715405597\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003cspan class\u003d\"tex-font-size-small\"\u003eThe blue numbers on the candies correspond to $$$b_i$$$ values. The image corresponds to the $$$1$$$-st example.\u003c/span\u003e \u003c/center\u003e\u003cp\u003eThe train has infinite capacity, and it is possible to load off any number of candies at a station. However, only \u003cspan class\u003d\"tex-font-style-bf\"\u003eat most one\u003c/span\u003e candy can be loaded from a station onto the train before it leaves the station. You can choose any candy at this station. The time it takes to move the candies is negligible.\u003c/p\u003e\u003cp\u003eNow, Alice wonders how much time is needed for the train to deliver all candies. Your task is to find, for each station, the minimum time the train would need to deliver all the candies were it to start from there.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$2 \\leq n \\leq 100$$$; $$$1 \\leq m \\leq 200$$$) — the number of stations and the number of candies, respectively.\u003c/p\u003e\u003cp\u003eThe $$$i$$$-th of the following $$$m$$$ lines contains two space-separated integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \\leq a_i, b_i \\leq n$$$; $$$a_i \\neq b_i$$$) — the station that initially contains candy $$$i$$$ and the destination station of the candy, respectively.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eIn the first and only line, print $$$n$$$ space-separated integers, the $$$i$$$-th of which is the minimum time, in seconds, the train would need to deliver all the candies were it to start from station $$$i$$$.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 7\n2 4\n5 1\n2 3\n3 4\n4 1\n5 3\n3 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e10 9 10 10 9 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2 3\n1 2\n1 2\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5 6 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eConsider the second sample.\u003c/p\u003e\u003cp\u003eIf the train started at station $$$1$$$, the optimal strategy is as follows.\u003c/p\u003e\u003col\u003e \u003cli\u003e Load the first candy onto the train. \u003c/li\u003e\u003cli\u003e Proceed to station $$$2$$$. This step takes $$$1$$$ second. \u003c/li\u003e\u003cli\u003e Deliver the first candy. \u003c/li\u003e\u003cli\u003e Proceed to station $$$1$$$. This step takes $$$1$$$ second. \u003c/li\u003e\u003cli\u003e Load the second candy onto the train. \u003c/li\u003e\u003cli\u003e Proceed to station $$$2$$$. This step takes $$$1$$$ second. \u003c/li\u003e\u003cli\u003e Deliver the second candy. \u003c/li\u003e\u003cli\u003e Proceed to station $$$1$$$. This step takes $$$1$$$ second. \u003c/li\u003e\u003cli\u003e Load the third candy onto the train. \u003c/li\u003e\u003cli\u003e Proceed to station $$$2$$$. This step takes $$$1$$$ second. \u003c/li\u003e\u003cli\u003e Deliver the third candy. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eHence, the train needs $$$5$$$ seconds to complete the tasks.\u003c/p\u003e\u003cp\u003eIf the train were to start at station $$$2$$$, however, it would need to move to station $$$1$$$ before it could load the first candy, which would take one additional second. Thus, the answer in this scenario is $$$5+1 \u003d 6$$$ seconds.\u003c/p\u003e"}}]}