{"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":"\u003cdiv class\u003d\"epigraph\"\u003e\u003cdiv class\u003d\"epigraph-text\"\u003e\u003ca href\u003d\"https://soundcloud.com/kivawu/hyouryu\"\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eTHE SxPLAY \u0026amp; KIVΛ - 漂流\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e \u003cdiv class\u003d\"epigraph\"\u003e\u003cdiv class\u003d\"epigraph-text\"\u003e\u003ca href\u003d\"https://soundcloud.com/kivawu/perspectives\"\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eKIVΛ \u0026amp; Nikki Simmons - Perspectives\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003cp\u003eWith a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space.\u003c/p\u003e\u003cp\u003eThe space can be considered a 2D plane, with an infinite number of data nodes, indexed from $$$0$$$, with their coordinates defined as follows:\u003c/p\u003e\u003cul\u003e \u003cli\u003e The coordinates of the $$$0$$$-th node is $$$(x_0, y_0)$$$ \u003c/li\u003e\u003cli\u003e For $$$i \u0026gt; 0$$$, the coordinates of $$$i$$$-th node is $$$(a_x \\cdot x_{i-1} + b_x, a_y \\cdot y_{i-1} + b_y)$$$ \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eInitially Aroma stands at the point $$$(x_s, y_s)$$$. She can stay in OS space for at most $$$t$$$ seconds, because after this time she has to warp back to the real world. She \u003cspan class\u003d\"tex-font-style-bf\"\u003edoesn\u0027t\u003c/span\u003e need to return to the entry point $$$(x_s, y_s)$$$ to warp home.\u003c/p\u003e\u003cp\u003eWhile within the OS space, Aroma can do the following actions:\u003c/p\u003e\u003cul\u003e \u003cli\u003e From the point $$$(x, y)$$$, Aroma can move to one of the following points: $$$(x-1, y)$$$, $$$(x+1, y)$$$, $$$(x, y-1)$$$ or $$$(x, y+1)$$$. This action requires $$$1$$$ second. \u003c/li\u003e\u003cli\u003e If there is a data node at where Aroma is staying, she can collect it. We can assume this action costs $$$0$$$ seconds. Of course, each data node can be collected at most once. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eAroma wants to collect as many data as possible before warping back. Can you help her in calculating the maximum number of data nodes she could collect within $$$t$$$ seconds?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains integers $$$x_0$$$, $$$y_0$$$, $$$a_x$$$, $$$a_y$$$, $$$b_x$$$, $$$b_y$$$ ($$$1 \\leq x_0, y_0 \\leq 10^{16}$$$, $$$2 \\leq a_x, a_y \\leq 100$$$, $$$0 \\leq b_x, b_y \\leq 10^{16}$$$), which define the coordinates of the data nodes.\u003c/p\u003e\u003cp\u003eThe second line contains integers $$$x_s$$$, $$$y_s$$$, $$$t$$$ ($$$1 \\leq x_s, y_s, t \\leq 10^{16}$$$)\u0026nbsp;– the initial Aroma\u0027s coordinates and the amount of time available.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint a single integer\u0026nbsp;— the maximum number of data nodes Aroma can collect within $$$t$$$ seconds.\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\u003e1 1 2 3 1 0\n2 4 20\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\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\u003e1 1 2 3 1 0\n15 27 26\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\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\u003e1 1 2 3 1 0\n2 2 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\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\u003eIn all three examples, the coordinates of the first $$$5$$$ data nodes are $$$(1, 1)$$$, $$$(3, 3)$$$, $$$(7, 9)$$$, $$$(15, 27)$$$ and $$$(31, 81)$$$ (remember that nodes are numbered from $$$0$$$).\u003c/p\u003e\u003cp\u003eIn the first example, the optimal route to collect $$$3$$$ nodes is as follows: \u003c/p\u003e\u003cul\u003e \u003cli\u003e Go to the coordinates $$$(3, 3)$$$ and collect the $$$1$$$-st node. This takes $$$|3 - 2| + |3 - 4| \u003d 2$$$ seconds. \u003c/li\u003e\u003cli\u003e Go to the coordinates $$$(1, 1)$$$ and collect the $$$0$$$-th node. This takes $$$|1 - 3| + |1 - 3| \u003d 4$$$ seconds. \u003c/li\u003e\u003cli\u003e Go to the coordinates $$$(7, 9)$$$ and collect the $$$2$$$-nd node. This takes $$$|7 - 1| + |9 - 1| \u003d 14$$$ seconds. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eIn the second example, the optimal route to collect $$$2$$$ nodes is as follows: \u003c/p\u003e\u003cul\u003e \u003cli\u003e Collect the $$$3$$$-rd node. This requires no seconds. \u003c/li\u003e\u003cli\u003e Go to the coordinates $$$(7, 9)$$$ and collect the $$$2$$$-th node. This takes $$$|15 - 7| + |27 - 9| \u003d 26$$$ seconds. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eIn the third example, Aroma can\u0027t collect any nodes. She should have taken proper rest instead of rushing into the OS space like that.\u003c/p\u003e"}}]}