Write a program that reports the current ranking of drivers in a car race.
The closed race track has K checkpoints numbered from 1 to K. A judge is stationed at each checkpoint. Whenever a driver passes a checkpoint, that judge sends the computer system a message containing the driver's number and the checkpoint number. Drivers are numbered from 1 to N.
The race starts just before checkpoint 1, so a driver's first valid checkpoint pass must be checkpoint 1. After checkpoint K, the next valid checkpoint is checkpoint 1 again.
Drivers must pass checkpoints in this order. If a message says that a driver passed a checkpoint other than that driver's next required checkpoint, ignore that message.
A driver who has validly passed more checkpoints is ranked higher. If two drivers have validly passed the same number of checkpoints, the driver whose most recent valid checkpoint pass happened earlier is ranked higher.

The figure shows a track with five checkpoints. Drivers must pass checkpoints in the correct order; extra checkpoint passes between two consecutive required checkpoints are ignored.
The first line contains three integers K, N, and M.
1 <= K <= 1001 <= N <= 1001 <= M <= 10000Each of the next M lines contains two integers X and Y, meaning that driver X passed checkpoint Y.
Messages are given in chronological order.
The given test data always determines a valid ranking.
Print one line containing the final ranking of all drivers after all M messages have been processed.