I`ve Got Your Back(gammon)
A friend of yours is working on an AI program to play backgammon, and she has a small problem. At the end of the game, each player's 15 pieces are moved onto a set of 6 board positions called points, numbered 1 through 6. The pieces can be distributed in any manner across these points: all 15 could be on point 3; 5 could be on point 6, 2 on point 5, 3 on point 4 and 5 on point 2; etc. Your friend wants to store all these possible con gurations (of which there are 15504) into a linear array, but she needs a mapping from con guration to array location. It seems logical that the con guration with all 15 pieces on point 1 should correspond to array location 0, and the con guration of all 15 pieces on point 6 should correspond to the last array location. It's the ones in between that are giving her problems. That's why she has come to you.
You decide to specify a con guration by listing the number of pieces on each point, starting with point 6. For example, the two con gurations described above could be represented by (0, 0, 0, 15, 0, 0) and (5, 2, 3, 0, 5, 0). Then you can order the con gurations in lexicographic ordering, starting with (0, 0, 0, 0, 0, 15), then (0, 0, 0, 0, 1, 14), (0, 0, 0, 0, 2,13), ..., (0, 0, 0, 0, 14, 1), (0, 0, 0, 0, 15, 0), (0, 0, 0, 1, 0, 14), (0, 0, 0, 1, 1, 13), etc., ending with (15, 0, 0, 0, 0, 0). Now all you need is a way to map these orderings to array indices. Literally, that's all you need, because that's what this problem is all about.
Input
Each test case will consist of one line, starting with a single character, either 'm' or 'u'. If it is an 'm' it will be followed by a con guration and you must determine what array index it gets mapped to. If it is a 'u' then it will be followed by an integer array index i, 0 ≤ i < 15504, and you must determine what con guration gets mapped to it. A line containing the single character 'e' will end input.
Output
For each test case, output the requested answer - either an array index or a con guration. Follow the format in the examples below.