<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_r_ending(stem: str) -> str: """ Adds an -r ending to an Old Norse noun. 'armr' 'áss' 'stóll' 'jökull' 'steinn' 'mikill' 'sæll' 'litill' 'vænn' 'lauss' 'vinr' 'selr' 'fagr' 'vitr' 'vetr' 'akr' 'björn' 'þurs' 'karl' 'hrafn' :param stem: :return: """

    s_stem = s.syllabify_ssp(stem.lower())
    n_stem = len(s_stem)
    last_syllable = Syllable(s_stem[-1], VOWELS, CONSONANTS)
    return "".join(s_stem[:-1]) + add_r_ending_to_syllable(last_syllable.text, n_stem == 1)