34. On a straight road running from north to south, there stands a cart driven by a Swan. Exactly at midnight, a Crab and a Pike chose natural numbers $m>n$. Every $n$ minutes (i.e., after $n, 2 n, 3 n \ldots$ minutes past midnight), the Pike commands "South!", and every $m$ minutes (after $m, 2 m, 3 m \ldots$ minutes past midnight), the Crab commands "North!". Upon hearing any command, the Swan immediately starts (or continues) pulling the cart in the indicated direction at a speed of 1 m/min. Before the first command, the cart was stationary. After $m n$ minutes past midnight, the Crab and the Pike gave the Swan two different commands for the first time, and the exhausted Swan stopped the cart. At what distance from the starting point did it end up at this moment?

(K. Tyschuk)
34. Answer: the cart moved $(m-n) n$ meters.

It is not hard to see that the cart stopped when the Carp gave the $m$-th command, and the Crab gave the $n$-th command. For convenience, we will call the interval between successive commands of the Carp (as well as the interval between midnight and the first command) an hour (this will not lead to any misunderstanding, as we will not use considerations about the duration of such an hour). Thus, from midnight to the end of the ride, $m$ hours passed. Since $m>n$, the Crab could command no more than once per hour.

Consider the hour containing the $k$-th command of the Crab, as well as the hour when the $(n-k)$-th command of the Crab was given. In the figure below, we took $k=2$, the hours of interest are marked on the time axis with curly braces. Since the entire ride lasted an integer number of hours, the $k$-th command of the Crab was given $m k$ minutes after midnight, and the $(n-k)$-th command of the Crab was given $m k$ minutes before the stop, the considered hours are symmetrical: in the first, from the beginning of the hour to the command of the Crab, as many minutes passed as in the second from the command of the Crab to the end of the hour. Then it is clear that during these two hours, the cart traveled equal distances north and south. (For the hours under consideration, the intervals of time when the cart moved south are shown on the diagram with a solid line, and north with a dashed line.)

Therefore, the displacement of the cart is determined only by those hours during which the Crab did not give a command. There are $m-n$ such hours, during each of which the cart traveled $n$ minutes south.

Thus, Sasha can always make such a move that Andrey cannot win on his next move. It remains to understand that Sasha will win, for which he needs to get a number with exactly 2018 digits. This, of course, will happen: after 671 pairs of moves and one more move by Sasha, there will be exactly $4+3 \cdot 671+1=$ $=2018$ digits.