In the event of technical difficulties with Szkopuł, please contact us via email at email@example.com.
If you are familiar with IRC chat, the support team is also reachable on PIRC network (
#szkopul channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
ByteGuy owns a strong-box protected with a lock. This lock has knobs. Each knob can be situated in one of possible positions.
ByteGuy has not used his strong-box for a long time now, so he has forgotten the configuration of knobs which opens the strong-box. He went to the company producing locks, where he learned about construction of the lock. It consists of knobs and the same number of bolts. All of them (both bolts and knobs) can be in one of allowed positions numbered from to . The lock opens, when all of the bolts are set to the position . Turning -th knob by one position (from position to , from to , , from to , from to ) causes, that -th bolt rotates by positions (from position to ). The manufacturer of locks helped ByteGuy and gave him a modern 3D-scaner, which allowed to check the configuration of the bolts hidden inside a strong-box.
Locks manufactured for strong-boxes are of high quality and there is only one configuration of knobs which opens the lock.
Write a program, which:
The first line contains two integers - the number of knobs, and the prime number - the number of possible positions of knobs, . The following line contains integers in the range - positions, in which successive knobs are located. The third line contains integers from the range - positions of consecutive bolts of ByteGuy's strong-box. Following lines contain descriptions of consecutive knobs - -th of these lines contains exactly integers - , , , , .
The only line of output should contain integers from the range , separated with single spaces - the configuration of knobs which opens the lock.
For the input data:
2 3 1 1 2 2 1 0 0 1
the correct result is:
Task author: Piotr Stanczyk.