Question: I have this summation
[Check the image](https://i.stack.imgur.com/RMCGl.png)

How did I get the RHS of answer?

Answer: 
We seek to prove: $\vdash (\neg p\to q)\to((\neg p\to\neg q)\to p)$

A method to prove $\phi\to (\psi\to \chi)$, would be to assume $\phi$ and $\psi$ then make an argument to conclude $\chi$, then discharge the assumptions with conditional introduction.

So then, can you make an argument for $p$ made under an assumption of $\neg p\to q$ and $\neg p \to\neg q$ ?

$$\begin{array}{r|l:l}
1. & \quad \neg p\to q & \text{Assumption}\\
2. & \qquad \neg p\to\neg q & \text{Assumption}\\
\vdots & \qquad\quad\vdots & \vdots \\
n. & \qquad p & \\
n+1. & \quad (\neg p\to\neg q)\to p&2,n,\text{Conditional Introduction}\\
n+2. & (\neg p\to q)\to((\neg p\to\neg q)\to p)&1,n+1,\text{Conditional Introduction}\\
\end{array}$$
*Hint*

Assume $\lnot p$ and derive both $q$ and $\lnot q$.

Having reached a contradiction, we can use it to derive $\lnot \lnot p$ by $\lnot$-intro, discharging the assumption, and conclude by *Double Negation*.