I actually need to find a number $m$ which satisifes $m \equiv 18\,( mod\ 19)$ and $m\equiv 22\,(mod\ 23)$
I know Wilson theorem, which says $18! \equiv 18(mod\ 19)$ and $ 22! \equiv 22(mod\ 23)$. So I'm getting two distinct numbers, need to choose a single one which works for both.
We have $19|m+1$ and $23|m+1$
Let $n=m+1$, then $lcm(19,23)=437|n$
Thus n can be $437k$ for all $k \in Z$
Hence $m=437k-1$