Find a rational function $R(x)$ such that:

$1)$ For $i\in\{1,\dots,g\}$, $x_{i}=x_{i-1}+g$ with $x_0=0$.

$2)$ For $i\in\{0,\dots,g-1\}$ $R(x_i)=R(x_i+1)=\dots=R(x_i+g-1)=i+1$.

$3)$ $R(x_g)=g+1$.

So $R(x)$ is defined at $g^2+1$ points.

These points and the value taken by these points have an arithmetic progression structure and I know that Lagrange interpolation gives $O(g^2)$ polynomial.

However is there a degree $O(g)$ rational function $R(x)$ that takes advantages of the structure in the conditions?