irregularOrdinals = {
	:    ,
	:    ,
	:  ,
	:   ,
	:  ,
	:   ,
	: ,
}

def num2ordinal(n):
    conversion = int(float(n))
    num = spell_integer(conversion)
    hyphen = num.rsplit(, 1)
    num = num.rsplit(, 1)
    delim = 
    if len(num[-1]) > len(hyphen[-1]):
        num = hyphen
        delim = 

    if num[-1] in irregularOrdinals:
        num[-1] = delim + irregularOrdinals[num[-1]]
    elif num[-1].endswith():
        num[-1] = delim + num[-1][:-1] + 
    else:
        num[-1] = delim + num[-1] + 
    return .join(num)

if __name__ == :
    tests = .split()
    for num in tests:
        print(.format(num, num2ordinal(num)))




TENS = [None, None, , , ,
        , , , , ]
SMALL = [, , , , , ,
         , , , , , ,
         , , , ,
         , , , ]
HUGE = [None, None] + [h +  
                       for h in (, , , , , , 
                                  , , , )]

def nonzero(c, n, connect=''):
    return  if n == 0 else connect + c + spell_integer(n)

def last_and(num):
    if ',' in num:
        pre, last = num.rsplit(',', 1)
        if ' and ' not in last:
            last = ' and' + last
        num = ''.join([pre, ',', last])
    return num

def big(e, n):
    if e == 0:
        return spell_integer(n)
    elif e == 1:
        return spell_integer(n) + 
    else:
        return spell_integer(n) +  + HUGE[e]

def base1000_rev(n):
    
    
    while n != 0:
        n, r = divmod(n, 1000)
        yield r

def spell_integer(n):
    if n < 0:
        return  + spell_integer(-n)
    elif n < 20:
        return SMALL[n]
    elif n < 100:
        a, b = divmod(n, 10)
        return TENS[a] + nonzero(, b)
    elif n < 1000:
        a, b = divmod(n, 100)
        return SMALL[a] +  + nonzero(, b, ' and')
    else:
        num = .join([big(e, x) for e, x in
                         enumerate(base1000_rev(n)) if x][::-1])
        return last_and(num)