The mythical F-flat-Major scale, boasting a total of 8 flats.
We now know how the 12 notes in an octave are named, but pressing random keys on a piano keyboard is
still unlikely to produce good-sounding music (unless you stick to the white-keys only). Most music
doesn't use all 12 notes in any given work, but rather a subset of 7 of those notes in a Scale.
Scales are created by selecting some note as the Root Note, then stacking intervals on top of it in
either half steps (written as h and equivalent to a Minor 2nd interval), or whole steps
(written as w and equivalent to a Major 2nd interval). To form a Major Scale, the intervals
above some Root Note are in the order wwhwwwh. So starting at C and applying the stacking rules we
get the C-Major scale C D E F G A B C. There just so happens to be no sharps nor flats in this scals,
and we'll see why in one momement.
Before then, let's consider the D-Major scale which is D E F# G A B C# D. We see that there are 2
sharps in this scale - the collection of sharps or flats in a given scale is called the Key Signature.
That example may seem straightforward, but what about the F-Major scale? F G A A# C D E F, right?
Actually, there is a rule that each note name must be represented at least once, and so the correct
notes would be written as F G A Bb C D E F.
But what about a D#-Major Scale? The D-Major scale already has an F# as the third degree of the
scale, so in the D#-Major scale we simply give it an additional sharp to raise the note value once more,
yeilding the scale D# E# F## G# A# B# C## D#. The same goes for flats, with the Fb-Major scale being
Fb Gb Ab Bbb Cb Db Eb Fb.
This is technically all you need to know to solve the problem. However if things are still a bit confusing, let's try to explain it in the traditional method using the model of the Circle of Fifths.
The Circle of Fifths for Major Keys.
The Circle of Fifths is a visual tool that musicians use in order to quickly calculate the key signature
for any given root note. First let's observe that C-Major as 0 sharps, G-Major as 1 sharp, and
D-Major as 2 sharps. As we keep moving the root note up by a perfect fifth interval we can add one
sharp. Likewise there is 1 flat in F-Major, 2 flats in Bb-Major, and 3 flats in Eb-Major,
and so moving the root note downwards by the same interval adds flats instead.
The first sharp to be added is F#, then each additional sharp is one perfect fifth interval lower
than the previous, in the order F#, C#, G#, ... and so forth.
Likewise the first flat is Bb, and each additional flat is one perfect fifth interval higher than
the previous, in the order Bb, Eb, Ab, ... and so forth.
Input Data
First line is Q, the quantity of testcases.
Q lines will then follow, each holding one root note name.
Answer
Should consist of 7 * Q space-separated note names corresponding to the first 7 intervals of each
given root note's Major scale.
Example
input data:
2
Db
E#
answer:
Db Eb F Gb Ab Bb C E# F## G## A# B# C## D##