Anyway, one way of doing the coding is called Godel numbering. For a sequence of numbers, a1, a2, a3 ... aN, the Godel number, written [a1,a2,a3,...aN], is defined as
(sorry, this formula looks really cool if you have something like LaTeX to typeset it. HTML doesn't do it justice). The a values are arbitrary numbers (each value represents one statement in the language). The p numbers are prime numbers. p1 = 2, p2 = 3, p3 = 5, etc. A Godel number takes each p and raises it the its corresponding a power, and multiplies all them together. The Godel number of [1, 3] is 2^1 * 3^3 = 54. As you can see, Godel numbers tend to get quite large (which is ok. in theory of comp, we care about being able to do something, not how practical it is to actually do it...)
You can also take a number, and figure out the sequence that generated (this is just prime factorization). The sequence is unique, provided it doesn't end in 0s.
In this problem, you'll be converting Godel numbers to their sequences, and taking sequences giving their Godel numbers. For this problem, you may assume that you will need, at most, the first 80 primes.
Each test case spans multiple lines. The first line of a test case will consist of exactly one character, either a G or a I.
If the first line had a G on it, the next line will be a number, N. N is between 1 and 80 inclusive. Following that line, will start a string of N numbers, separated by an arbitrary amount of white space. The list of numbers may span multiple lines. However, after the last number, there will be a end of line character (ie, another test will not start on the same line that the previous case ended on). All numbers are positive integers.
If the first line had an I on it, the next line will contain a single number. That number is a Godel number of some sequence, and is greater than 0.
There are multiple test cases in the input. No blank lines will ever appear. No characters, other than the ones described above will appear.
For `G' input, print the Godel number of that sequence. The Godel number will fit within an unsigned 32 bit integer.
For `I' input, print the sequence determined by that Godel number. Print, at most, 20 numbers per line. Each number should be separated by a space. There should be no trailing 0s in your sequence (although, there may be 0s in your sequence, there should be none at the end).
No blank lines should appear in your output.
G 2 1 3 G 10 1 0 0 0 0 0 1 1 0 1 I 498
54 18734 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1