Solenn has many suitors. To pick a partner, she has the following criteria: her partner's height and weight must be close to hers. Her suitors also want to know how many suitors ranked ahead of them (maybe they want to "get rid" of the other suitors?).

Your task is to help Solenn rank her suitors based on her criteria. The suitors with small height differences with her must be at the top, and the suitors with big height differences must be at the bottom. If there are ties, break the tie according to their weight differences. If there are still ties, rank them alphabetically (yes, she is that superficial, unfortunately).


First line contains the number of problems to be solved, say X. This is followed by X number of chunks of data in this format: First line of the chunk contains two numbers, which is Solenn's height(in centimeters) and weight(in kg) separated by space. This is followed by a number, say s, which is the number of suitors Solenn has. This is then followed by s lines of data for each suitor which is formatted this way: "<name> <height in centimeters> <weight in kg>"


For each problem, print the ordering of Solenn's suitors (names only) based on her criteria, where the first one has the best score, separated by space.   
** Example Input:**
        170 60
        Allen       168     58
        Wendell     166     60
        Marlon      165     60
        Brian       165     60
        Christopher 172     57
        Rene        175     65
        Mark        169     75
        Kelvin      170     58
    **Expected Output:**
        Kelvin Mark Allen Christopher Wendell Brian Marlon Rene`

must be implemented/code using C. I badly need an answer asap.

You won't find anyone here who will write your program for you, so you might as well try to do it then post the questions you have.

ok. I'll try doing it today. but if you have any idea on how.pls share. I still have a lot more problems to code. I'm practicing for a codefest.