{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003ch1\u003ePLAY in BASIC\u003c/h1\u003e\n\n\u003cp\u003e\nOne sunny day, Dick T. Mustang found an ancient personal computer in the closet.\nHe brought it back to his room and turned it on with a sense of nostalgia, seeing a message coming on the screen:\n\u003c/p\u003e\n\n\u003cpre\u003eREADY?\n\u003c/pre\u003e\n\n\u003cp\u003e\nYes. BASIC.\n\u003c/p\u003e\n\n\u003cp\u003e\nBASIC is a programming language designed for beginners, and was widely used from 1980\u0027s to 1990\u0027s.\nThere have been quite a few BASIC dialects.\nSome of them provide the PLAY statement, which plays music when called with a string of a musical score written in Music Macro Language (MML).\nDick found this statement is available on his computer and accepts the following commands in MML:\n\u003c/p\u003e\n\n\u003cdl\u003e\n\u003cdt\u003eNotes: Cn, C+n, C-n, Dn, D+n, D-n, En,...,... (n \u003d 1,2,4,8,16,32,64,128 + dots)\u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eEach note command consists of a musical note followed by a duration specifier.\u003c/p\u003e\n\u003cp\u003eEach musical note is one of the seven basic notes: \u0027C\u0027, \u0027D\u0027, \u0027E\u0027, \u0027F\u0027, \u0027G\u0027, \u0027A\u0027, and \u0027B\u0027. It can be followed by either \u0027+\u0027 (indicating a sharp) or \u0027-\u0027 (a flat). The notes \u0027C\u0027 through \u0027B\u0027 form an octave as depicted in the figure below. The octave for each command is determined by the current octave, which is set by the octave commands as described later. It is not possible to play the note \u0027C-\u0027 of the lowest octave (1) nor the note \u0027B+\u0027 of the highest octave (8).\u003c/p\u003e\n\u003cp\u003eEach duration specifier is basically one of the following numbers: \u00271\u0027, \u00272\u0027, \u00274\u0027, \u00278\u0027, \u002716\u0027, \u002732\u0027, \u002764\u0027, and \u0027128\u0027, where \u00271\u0027 denotes a whole note, \u00272\u0027 a half note, \u00274\u0027 a quarter note, \u00278\u0027 an eighth note, and so on. This specifier is \u003ci\u003eoptional\u003c/i\u003e; when omitted, the duration will be the default one set by the L command (which is described below). In addition, duration specifiers can contain \u003ci\u003edots\u003c/i\u003e next to the numbers. A dot adds the half duration of the basic note. For example, \u00274.\u0027 denotes the duration of \u00274\u0027 (a quarter) plus \u00278\u0027 (an eighth, i.e. half of a quarter), or as 1.5 times long as \u00274\u0027. It is possible that a single note has more than one dot, where each extra dot extends the duration by half of the previous one. For example, \u00274..\u0027 denotes the duration of \u00274\u0027 plus \u00278\u0027 plus \u002716\u0027, \u00274...\u0027 denotes the duration of \u00274\u0027 plus \u00278\u0027 plus \u002716\u0027 plus \u002732\u0027, and so on. The duration extended by dots cannot be shorter than that of \u0027128\u0027 due to limitation of Dick\u0027s computer; therefore neither \u0027128.\u0027 nor \u002732...\u0027 will be accepted. The dots specified without the numbers extend the default duration. For example, \u0027C.\u0027 is equivalent to \u0027C4.\u0027 when the default duration is \u00274\u0027. Note that \u0027C4C8\u0027 and \u0027C4.\u0027 are \u003ci\u003eunequivalent\u003c/i\u003e; the former contains two distinct notes, while the latter just one note.\u003c/p\u003e\u003c/dd\u003e\n\u003cdt\u003eRest: Rn (n \u003d 1,2,4,8,16,32,64,128 + dots)\u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eThe R command rests for the specified duration. The duration should be specified in the same way as the note commands, and it can be omitted, too. Note that \u0027R4R8\u0027 and \u0027R4.\u0027 are \u003ci\u003eequivalent\u003c/i\u003e, unlike \u0027C4C8\u0027 and \u0027C4.\u0027, since the both rest for the same duration of \u00274\u0027 plus \u00278\u0027.\u003c/p\u003e\u003c/dd\u003e\n\u003cdt\u003eOctave: On (n \u003d 1-8), \u0026lt;, \u0026gt;\u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eThe O command sets the current octave to the specified number. \u0027\u0026gt;\u0027 raises one octave up, and \u0027\u0026lt;\u0027 drops one down. It is not allowed to set the octave beyond the range from 1 to 8 by these commands. The octave is initially set to 4.\u003c/p\u003e\u003c/dd\u003e\n\u003cdt\u003eDefault duration: Ln (n \u003d 1,2,4,8,16,32,64,128)\u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eThe L command sets the default duration. The duration should be specified in the same way as the note commands, but \u003ci\u003ecannot be omitted nor followed by dots\u003c/i\u003e. The default duration is initially set to 4.\u003c/p\u003e\u003c/dd\u003e\n\u003cdt\u003eVolume: Vn (n \u003d 1-255)\u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eThe V command sets the current volume. Larger is louder. The volume is initially set to 100.\u003c/p\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ccenter\u003e\n\u003cimg src\u003d\"CDN_BASE_URL/6f554e8b7b9b15bc862bab7f946a2f0f?v\u003d1715981800\" height\u003d\"192\" width\u003d\"570\"\u003e\n\u003c/center\u003e\n\n\u003cp\u003e\nAs an amateur composer, Dick decided to play his pieces of music by the PLAY statement.\nHe managed to write a program with a long MML sequence, and attempted to run the program to play his music -- but unfortunately he encountered an unexpected error: the MML sequence was too long to be handled in his computer\u0027s small memory!\n\u003c/p\u003e\n\n\u003cp\u003e\nSince he didn\u0027t want to give up all the efforts he had made to use the PLAY statement, he decided immediately to make the MML sequence shorter so that it fits in the small memory.\nIt was too hard for him, though.\nSo he asked you to write a program that, for each given MML sequence, prints the shortest MML sequence (i.e. MML sequence containing minimum number of characters) that expresses the same music as the given one.\nNote that the final values of octave, volume, and default duration can be differrent from the original MML sequence.\n\u003c/p\u003e\n\n\u003ch2\u003eInput\u003c/h2\u003e\n\n\u003cp\u003e\nThe input consists of multiple data sets. Each data set is given by a single line that contains an MML sequence up to 100,000 characters.\nAll sequences only contain the commands described above.\nNote that each sequence contains at least one note, and there is no rest before the first note and after the last note.\n\u003c/p\u003e\n\n\u003cp\u003e\nThe end of input is indicated by a line that only contains \"*\".\nThis is not part of any data sets and hence should not be processed.\n\u003c/p\u003e\n\n\u003ch2\u003eOutput\u003c/h2\u003e\n\n\u003cp\u003e\nFor each test case, print its case number and the shortest MML sequence on a line.\n\u003c/p\u003e\n\n\u003cp\u003e\nIf there are multiple solutions, print any of them.\n\u003c/p\u003e\n\n\u003ch2\u003eSample Input\u003c/h2\u003e\n\n\u003cpre\u003eC4C4G4G4A4A4G2F4F4E4E4D4D4C2\nO4C4.C8F4.F8G8F8E8D8C2\nB-8\u0026gt;C8\u0026lt;B-8V40R2R..R8.V100EV50L1CG\n*\n\u003c/pre\u003e\n\n\u003ch2\u003eOutput for the Sample Input\u003c/h2\u003e\n\n\u003cpre\u003eCase 1: CCGGAAG2FFEEDDC2\nCase 2: C.C8F.L8FGFEDC2\nCase 3: L8B-B+B-RL1RE4V50CG\n\u003c/pre\u003e\n"}}]}