I have currently solved this on some weird assumption, but there are more analytical ways of solving this.