﻿using System;
using System.Linq;

class Ebonacci
{

    static void Main()
    {        
        string[] alphabet = new string [26] {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
                                   "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
                                   "U", "V", "W", "X", "Y", "Z"};

        string first = Console.ReadLine();
        string second = Console.ReadLine();
        int rows = int.Parse(Console.ReadLine());

        int firstValue = Array.IndexOf(alphabet, first) + 1;
        int secondValue = Array.IndexOf(alphabet, second) + 1;

        int nextValue = (firstValue + secondValue) % 26;
        //Console.WriteLine("next value is" + nextValue);
        int nextEbonaci = 0;
        string nextLetter = "";

        if (rows == 1)
        {
            Console.WriteLine(first);
            return;
        }

        if (rows == 0)
        {
            return;
        }

        Console.WriteLine(first);
        Console.Write(second);
        Console.WriteLine(alphabet.GetValue(nextValue - 1));

        firstValue = secondValue;
        secondValue = nextValue;
        //Console.WriteLine(firstValue + "    " + secondValue);

        for (int i = 2; i < rows; i++)
        {
            nextEbonaci = (firstValue + secondValue) % 26;

            if (nextEbonaci > 0)
            {
                nextLetter = (string)alphabet.GetValue(nextEbonaci - 1);
                firstValue = secondValue;
                secondValue = nextEbonaci;
            }

            else
            {
                nextLetter = (string)alphabet.GetValue(25);
                firstValue = secondValue;
                secondValue = nextEbonaci;
            }
            

            Console.Write(nextLetter);
            Console.Write(new string(' ', i - 1));

            nextEbonaci = (firstValue + secondValue) % 26;

            if (nextEbonaci > 0)
            {
                nextLetter = (string)alphabet.GetValue(nextEbonaci - 1);
                firstValue = secondValue;
                secondValue = nextEbonaci;
            }

            else
            {
                nextLetter = (string)alphabet.GetValue(25);
                firstValue = secondValue;
                secondValue = nextEbonaci;
            }

            Console.WriteLine(nextLetter);
        }
    }
}
