import math

def toKelvin(this, convertFrom):
    if convertFrom == "f":
        return (this + 459.67) * 5/9
    elif convertFrom == "c":
        return this + 273.15
    else:
        return "nope"

def toCelsius(this, convertFrom):
    if convertFrom == "f":
        return (this - 32) * 5/9
    elif convertFrom == "k":
        return this - 273.15
    else:
        return "nope"   

def toFahrenheit(this, convertFrom):
    if convertFrom == "c":
        return (this * 9/5) + 32
    elif convertFrom == "k":
        return (this * 9/5) - 459.67
    else:
        return "nope"

def toRadians(this, convertFrom):
    if convertFrom != "d":
        return "nope"
    else:
        return this * (math.pi / 180)

def toDegrees(this, convertFrom):
    if convertFrom != "r":
        return "nope"
    else:
        return this * (180 / math.pi)
    

def convert(this):
    convertFrom = this[-2:-1]
    convertTo = this[-1:]
    old = float(this[:-2])
    new = ""

    if convertTo == "d":
        new = toDegrees(old, convertFrom)
    elif convertTo == "r":
        new = toRadians(old, convertFrom)
    elif convertTo == "c":
        new = toCelsius(old, convertFrom)
    elif convertTo == "f":
        new = toFahrenheit(old, convertFrom)
    elif convertTo == "k":
        new = toKelvin(old, convertFrom)

    if new == "nope":
        return "No candidate for conversion"
    else:
        return (str(round(new, 2)) + convertTo)

def main():
    challenge = "3.1416rd\n90dr"
    bonus = "212fc\n70cf\n100cr\n315.15kc"

    t = bonus

    inputs = t.split('\n')
    outputs = []

    for i in range(len(inputs)):
        outputs.append(convert(inputs[i]))
        print(outputs[i])

main()
