The company Supersafe produces a safe with a combination lock. The lock of this safe consists of N cylinders on a common axis. Each cylinder revolves on this axis independently of other cylinders. The are numbers from 1 to M in a circle on each cylinder. At any time, one of these numbers is visible in a special window on the door of the safe. Thus it is possible to enter numbers by rotating the cylinders. Accordingly, the code of the safe is a sequence of N numbers, each number belonging to the interval from 1 to M.
As a rule, such safes have a mechanism for opening them in the case the code is forgotten or lost. For this model, the mechanism has two components:
The process of opening the safe is as follows. The specialist enters the technological code (not allowing the owner to see the code, of course), puts in the key, and then turns all cylinders until – click – the safe unlocks. After that, the specialist takes out the key and mixes up the obtained code by entering random numbers on all the cylinders.
You want to open one of such safes without the owner’s knowledge. For this purpose, you have obtained a copy of the safe key and found out that:
It remains to determine the technological code.
The input contains a single line with the values N and M. Both numbers are integers, belong to the interval from 2 to 20000 and are separated from each other by one or more spaces.
The output also consists of one line. It contains the technological code. The numbers in this line should be separated by one or more spaces.
Northeastern Europe 2003, Western Subregion
[Submit] [Go Back] [Status] [Discuss]
Home Page Go Back To top
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator