Implement pagination with forward and backward navigation.
Create paginate(items, page_size, actions), returning the page contents after each action. Start on the first page. next, forward, or n advances one page; prev, previous, backward, or p moves back one page. Attempts to move beyond either boundary leave the current page unchanged. Ignore unrecognized actions.
items is a non-empty list, page_size is positive, and actions is a list of strings. Return a list containing one page list per action.
def paginate(items, page_size, actions):