import java.util.Scanner;
import java.util.ArrayList;

public class A_Edstrom
{
	public static void main (String [] args)
	{
		//String [] notes = {"A","A#","B","C","C#","D","D#","E","F","F#","G","G#"};
		ArrayList<String> list = new ArrayList<String>();
		list.add("A");
		list.add("A#");
		list.add("B");
		list.add("C");
		list.add("C#");
		list.add("D");
		list.add("D#");
		list.add("E");
		list.add("F");
		list.add("F#");
		list.add("G");
		list.add("G#");
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		while (!line.equals("***"))
		{
			Scanner scan = new Scanner(line);
			ArrayList<String> notes = new ArrayList<String>();
			while(scan.hasNext())
			{
				String note = scan.next();
				String ans = new String(note);
				if (note.length() > 1)
				{
					if (note.charAt(1) == 'b')
					{
						if (note.toUpperCase().charAt(0) == 'A')
						{
							ans = "G#";
						}
						else
						{
							ans = "" + list.get(list.indexOf(""+note.toUpperCase().charAt(0)) - 1);
							
						}
					}
					else if (note.charAt(1) == '#' && !list.contains(note))
					{
						if (note.toUpperCase().charAt(0) == 'B')
							ans = "C";
						else if (note.toUpperCase().charAt(0) == 'E')
							ans = "F";
					}
				}
				notes.add(ans);
			}
			int t = Integer.parseInt(in.nextLine());
			String answer = "";
			//ArrayList<String> answer = new ArrayList<String>();
			for (String s : notes)
			{
				int n = 0;
				if (t >= 0)
					n = (list.indexOf(s) + t) % 12;
				else
				{
					int temp = (int)Math.abs(t);
					n = (list.indexOf(s) + 12 - (temp%12)) % 12;
				}
				//System.err.println("N is "+n);
				answer += list.get(n) + " ";
			}
			System.out.println(answer.trim());
			line = in.nextLine();
		}
	}
}
