It's said that "Writing a love-letter is mush easier than sending it out". After writing the love-letter with the help of ALM, Gardon is now planing how to send it to his Angel.
Er......In fact Gardon is too shy to send it directly. - -b So we needs to find some one to help him ...As the old saying goes "You should pay to get something". Gardon must spend some money to buy gifts to someone who helps him. And there are also rules to give somebody gifts:
1. Some helpers need a number of gift.
2. If you ask A to send some gifts to B, besides the quantity of gifts A ordered, you must also give the same quantity of gifts to A as many as gifts you ask A to give B.
For example, there are four people, Angel, Bred, Cici, Dennis. Bred orderd two gifts, Cici and Dennis asked only one for themselves, and the way to send the letter is: Gardon==>Dennis==>Cici==>Bred==>Angel, so Gardon will buy Cici totally three gifts(one orded,the other two are paid for Cici sending gifts to Bred), and buy Dennis totally six gifts (one orded, the other two are paid for Dennis sending gifts to Cici). So totally Gardon need to buy eleven gifts - Bred two, Cici three, and Dennis six.
Now, giving every body's name, the quantity of gifts he/she ordered, and all person he/she knows (One can ask anybody who he/she knows), could you tell Gardon how many gifts he need to buy?