Let $A,B\subset\mathbb{R},n\ge2$.
Let $f:A\to B$ (not necessarily continuous) such that $\forall a\in A,f^{-1}(a)$ is a tuple of $n$ elements.
I know that if $f$ in continuous, for $A=B=\mathbb{R}$ and $n=2$, such a function does not exist. Therefore I was wondering :
When does such a function exist ? When it does, can one give an explicit formula for such a function ?