<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def factory(resp):
 """ Return a ResponseError subclass based on the API payload. All errors are documented: https://docs.mollie.com/guides/handling-errors#all-possible-status-codes More exceptions should be added here when appropriate, and when useful examples of API errors are available. """

        status = resp['status']
        if status == 401:
            return UnauthorizedError(resp)
        elif status == 404:
            return NotFoundError(resp)
        elif status == 422:
            return UnprocessableEntityError(resp)
        else:
            # generic fallback
            return ResponseError(resp)