#Judje side, Goal
World=[[{'up': 'red', 'right': 'road', 'down': 'red', 'left': 'red'}, {'up': 'red', 'right': 'road', 'down': 'red', 'left': 'road'}, {'up': 'red', 'right': 'road', 'down': 'red', 'left': 'road'}, {'up': 'white', 'right': 'road', 'down': 'road', 'left': 'road'}, {'up': 'white', 'right': 'road', 'down': 'white', 'left': 'road'}, {'up': 'red', 'right': 'red', 'down': 'red', 'left': 'road'}], [{'up': '', 'right': '', 'down': '', 'left': ''}, {'up': '', 'right': '', 'down': '', 'left': ''}, {'up': '', 'right': '', 'down': '', 'left': ''}, {'up': 'road', 'right': 'white', 'down': 'road', 'left': 'red'}, {'up': '', 'right': '', 'down': '', 'left': ''}, {'up': '', 'right': '', 'down': '', 'left': ''}], [{'up': 'red', 'right': 'road', 'down': 'red', 'left': 'red'}, {'up': 'red', 'right': 'road', 'down': 'red', 'left': 'road'}, {'up': 'red', 'right': 'road', 'down': 'red', 'left': 'road'}, {'up': 'road', 'right': 'road', 'down': 'white', 'left': 'road'}, {'up': 'white', 'right': 'road', 'down': 'white', 'left': 'road'}, {'up': 'red', 'right': 'finish', 'down': 'red', 'left': 'road'}]]
IsFinished=False
RobotPosition=[0,0]

def SendMovement (Step):
    global RobotPosition
    global IsFinished
    result = 'Error'
    if Step=="up":
        #print ('try to up')
        if World[RobotPosition[1]][RobotPosition[0]]['up']=='road' or World[RobotPosition[1]][RobotPosition[0]]['up']=='finish':
            if World[RobotPosition[1]][RobotPosition[0]]['up']=='finish':
                IsFinished=True
            result = 'Moved up succesfully' # Moved up successfully
            RobotPosition[1]-=1
        else:
            result = 'Error' # Error
    if Step=="down":
        #print ('try to down')
        if World[RobotPosition[1]][RobotPosition[0]]['down']=='road' or World[RobotPosition[1]][RobotPosition[0]]['down']=='finish':
            if World[RobotPosition[1]][RobotPosition[0]]['down']=='finish':
                IsFinished=True
            result = 'Moved down succesfully' # Moved down successfully
            RobotPosition[1]+=1
        else:
            result = 'Error' # Error
    if Step=="left":
        #print ('try to left')
        if World[RobotPosition[1]][RobotPosition[0]]['left']=='road' or World[RobotPosition[1]][RobotPosition[0]]['left']=='finish':
            if World[RobotPosition[1]][RobotPosition[0]]['left']=='finish':
                IsFinished=True
            result = 'Moved left succesfully' # Moved left successfully
            RobotPosition[0]-=1
        else:
            result = 'Error' # Error
    if Step=="right":
        #print ('try to right')
        if World[RobotPosition[1]][RobotPosition[0]]['right']=='road' or World[RobotPosition[1]][RobotPosition[0]]['right']=='finish':
            if World[RobotPosition[1]][RobotPosition[0]]['right']=='finish':
                IsFinished=True
            result = 'Moved right succesfully' # Moved right successfully
            RobotPosition[0]+=1
        else:
            result = 'Error' # Error
    return result

def GetMeasurement():
    return World[RobotPosition[1]][RobotPosition[0]]
    #World[RobotPosition[0]][RobotPosition[1]]['up']
