Welcome to ZOJ
Information
Problems
Runs
Statistics
Ranklist
Clarification
96 - ZOJ Monthly, September 2010 - F
Guitar

Time Limit: 2 Seconds      Memory Limit: 65536 KB

The guitar is a plucked string instrument, played either with fingers or a pick. The guitar consists of a body with a rigid neck to which the strings, generally six in number.

Frets are metal strips (usually nickel alloy or stainless steel) embedded along the fretboard and located at exact points that divide the scale length in accordance with a specific mathematical formula. Pressing a string against a fret determines the strings' vibrating length and therefore its resultant pitch. The pitch of each consecutive fret is defined at a half-step interval on the chromatic scale.

Scales are typically listed from low to high. Most scales are octave-repeating, meaning their pattern of notes is the same in every octave. An octave-repeating scale can be represented as a circular arrangement of pitch classes, ordered by increasing pitch class. For instance, the increasing C major scale is, C-D-E-F-G-A-B-[C], with the bracket indicating that the last note is an octave higher than the first note. In scientific pitch notation, An octave-repeating scale C-D-E-F-G-A-B-[C] is written as Ci-Di-Ei-Gi-Ai-Bi-[Ci+1], i.e., if i = 4, it's C4-D4-E4-F4-G4-A4-B4-[C5]. The interval between two successive pitch is described in the pictures below, where HS = half-step and WS = whole-step:

Now, let's use a mathematical form to describe what was described above. In this problem, we define:

  • The pitch of Fret 0 is the pitch when you don't press any fret. Of course, there is also a half-step interval between Fret 0 and Fret 1.
  • The pitch on String i of Fret j is described by a mathematical formula p(i, j).
  • One half-step interval = 1. So p(i, j+1) - p(i, j) = 1 and F3 - E3 = 1.
  • One whole-step interval = 2. So D3 - C3 = 2.
  • The symbol # means a half-step higher, i.e. C3# - C3 = 1 and D3 - C3# = 1.
  • p(6, 0) = E3.
  • p(i, 0) = p(i+1, 5), i ≠ 2;
  • p(i, 0) = p(i+1, 4), i = 2;
You are given two operations as below:
  1. Chord: There are six numbers. The ith number Ki indicates now you press the String i at Fret Ki. (0 <= Ki <= 30)
  2. Play: There is one integer M indicating you play the String M.(1 <= M <= 6)
You won't shift the chord until you get another operation "Chord". And you start without pressing any string.

You should output the pitch you play using scientific pitch notation. See "Output" for more details.

Input

There are multiple cases. In each case, there is one of two operations described above in a single line. A single number 0 in a single line indicates the end of the case. There is a blank line between two cases.

Output

For each case, output the pitch you play using scientific pitch notation. If you can't use C D E F G A B to denote the pitch, add a symbol "#" after it, like C4#, D5# and etc., but E3# is forbidden because E3# = F3. Output every pitch in a single line. Output a blank line between two cases. All the cases contain at sleast two lines.

Sample Input

6
5
4
3
2
1
0

0 1 0 2 3 0
6
5
4
3
2
1
1 1 1 1 1 1
1
2
3
4
5
6
0

Sample Output

E3
A3
D4
G4
B4
E5

E3
C4
E4
G4
C5
E5
F5
C5
G4#
D4#
A3#
F3

Author: YU, Xiaoyao
Contest: ZOJ Monthly, September 2010
Submit    Status