Solve for d N=3qd-rd