#include <vector>
	#include <string>
	#include <algorithm>
	#include <iterator>
	#include <fstream>
	#include <sstream>
	#include <iostream>


	void ParseTablature(const std::string& input)
	{
		using namespace std;

		static const char* NoteOrder[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };

		istringstream file(input);
		if (file)
		{
			vector<unsigned int> noteBases;
			vector<istringstream> lines;
			do
			{
				string line;
				getline(file, line);
				lines.push_back(istringstream(line));
				noteBases.push_back(find(begin(NoteOrder), end(NoteOrder), line.substr(0, 1)) - begin(NoteOrder));
			} while (file);

			vector<unsigned int> octaves = { 4, 3, 3, 3, 2, 2 };
			fill_n(back_inserter(octaves), lines.size() - octaves.size(), 0); // For safety in case we have more than 6 lines (???)
			transform(noteBases.begin(), noteBases.end(), octaves.begin(), noteBases.begin(), [](auto noteBase, auto octave)
			{
				return noteBase + (octave * 12); // Encode base octave
			});

			while (any_of(lines.begin(), lines.end(), [](const auto& line) { return line.good(); }))
			{
				unsigned int lineIndex = 0;
				for (auto& line : lines)
				{
					if (line)
					{
						char first = line.get();
						if (isdigit(first))
						{
							string indexString;
							indexString += first;
							if (line)
							{
								char second = line.get();
								if (isdigit(second))
								{
									indexString += second;
								}
							}

							unsigned int noteIndex;
							istringstream indexStream(indexString);
							indexStream >> noteIndex;

							auto absoluteNote = noteIndex + noteBases[lineIndex];
							auto octave = absoluteNote / 12;
							auto relativeNote = absoluteNote % 12;

							cout << NoteOrder[relativeNote] << octave << " ";
						}
					}

					++lineIndex;
				}
			}
		}
	}

	int main(int argc, const char** argv)
	{
		std::string input;
		std::string line;
		std::cin >> line;
		while (line != "0")
		{
			input += line;
			input += '\n';
			std::cin >> line;
		}
		
		ParseTablature(input);
	}