In the reference frame attached to wedge of mass M the particle of mass m can only move horizontally.
FBD of wedge of mass M with respect to FBD of particle w.r.t. wedge of mass M ground
Applying Newton.s `2^(nd)` law of the particle
`N+ma_(wq)sin theta=mg " " ...(i)`
`ma_(wq)cos theta=ma_(mM)" "...(ii)`
Applying Newton.s `2^(nd)` law for wedge of mass M
`N sin theta+mg sin theta=Ma_(wq)" " ...(iii)`
Solving (i), (ii) and (iii) we get
`a_(wq)=((M+m)g sin theta)/(M+m sin^(2)theta)`
`N=(Mmgcos^(2)theta)/((M+m sin^(2)theta))`
`a_(mM)=((M+m)g sin theta cos theta)/(M+m sin^(2)theta)`