def decode(state):
    """
    decodes the taxi env state (int in [0,500) ) to:
    (taxirow, taxicol, passloc, destidx) tuple
    :param state: int in [0,500)
    :return: (taxirow, taxicol, passloc, destidx) tuple
    """
    destidx = state % 4
    state = state // 4
    passloc = state % 5
    state = state // 5
    taxicol = state % 5
    state = state // 5
    taxirow = state
    assert 0 <= state < 5
    return taxirow, taxicol, passloc, destidx