def extend_event(events, time, max_time):
    """Extends events in event list by time.
    
    The start time of each event is moved time seconds back and the end
    time is moved time seconds later
    
    Args:
        events: list of events. Each event is a tuple
        time: time to extend each event in seconds
        max_time: maximum end time allowed of an event.
    Return
        extended_events: list of events which each event extended.
    """
    extended_events = events.copy()
    for i, event in enumerate(events):
        extended_events[i] = [max(0, event[0] - time),
                                  min(max_time, event[1] + time)]
    return extended_events