def next_specific(square, next_type):
    if next_type not in ["R", "U"]:
        raise Exception("next_specific only intended for R and U")

    # R1=5, R2=15, R3=25, R4=35
    index = SQUARES.index(square)
    if next_type == "R":
        if 0 <= index < 5 or 35 < index:
            return "R1"
        elif 5 < index < 15:
            return "R2"
        elif 15 < index < 25:
            return "R3"
        elif 25 < index < 35:
            return "R4"
        else:
            raise Exception("Case should not occur")
    # U1=12, U2=28
    elif next_type == "U":
        if 0 <= index < 12 or index > 28:
            return "U1"
        elif 12 < index < 28:
            return "U2"
        else:
            return Exception("Case should not occur")
    else:
        raise Exception("Case should not occur")