Let $N$ be a positive integer and $p$ a prime not dividing $N$. Let $X_0(N)$ be the modular curve (over $\mathbb{Q}$) associated to the congruence subgroup $\Gamma_0(N)$, which is the subgroup of $\text{SL}_2(\mathbb{Z})$ consisting of upper triangular matrices modulo $N$. Let $\pi_1$ and $\pi_p$ be two degeneracy maps from $X_0(Np)$ to $X_0(N)$ defined by "forgetting the level $p$ structure" and "dividing by the level $p$ structure" on the associated moduli problem. If we identify $X_0(Np)(\mathbb{C})\simeq \Gamma_0(Np)\backslash(\mathbb{H} \cup \mathbb{P}^1(\mathbb{Q}))$ and $X_0(N)(\mathbb{C})\simeq \Gamma_0(N)\backslash(\mathbb{H} \cup \mathbb{P}^1(\mathbb{Q}))$, then we have
$$ \pi_1(z)=z \pmod {\Gamma_0(N)} ~~\text{ and }~~ \pi_p(z)=pz \pmod {\Gamma_0(N)}. $$ Let $w_p$ be the Atkin-Lehner involution on $X_0(Np)$ which satisfies $$ \pi_1\circ w_p = \pi_p. $$
Now, we want to understand how these maps send cusps explicitly. Let $C(Np)$ and $C(N)$ denote the sets of cusps on $X_0(Np)$ and $X_0(N)$, respectively. Then the maps $\pi_1$ and $\pi_p$ send $C(Np)$ to $C(N)$, and $w_p$ becomes an involution on $C(Np)$ by restriction. Let $$ S_1=\{ (\begin{smallmatrix} x \\ d \end{smallmatrix}) : d \mid N, ~(x, d)=1,~1\leq x \leq d, ~x \text{ taken modulo } (d, N/d) \} $$ and $$ S_2=\{ (\begin{smallmatrix} x \\ dp \end{smallmatrix}) : d \mid N, ~(x, dp)=1,~1\leq x \leq dp, ~x \text{ taken modulo } (dp, N/d) \}. $$ (Note that $(dp, N/d)=(d, N/d)$.) Then, we have $$ C(Np)=S_1 \cup S_2 ~\text{ and }~ C(N)=S_1 $$ (cf. Section 3.8 of Diamond-Shurman's book, A first course in modular forms). I think that from the description of the maps $\pi_1$ and $\pi_p$ on $X_0(Np)(\mathbb{C})$, we have $$ \pi_1((\begin{smallmatrix} x \\ d \end{smallmatrix}))=(\begin{smallmatrix} x \\ d \end{smallmatrix}) \text{ and } \pi_p((\begin{smallmatrix} x \\ d \end{smallmatrix}))= (\begin{smallmatrix} y \\ d \end{smallmatrix}), $$ where $y$ is the remainder of $px$ divided by $d$. Also, we have $$ \pi_1((\begin{smallmatrix} x \\ dp \end{smallmatrix}))=(\begin{smallmatrix} z \\ d \end{smallmatrix}) \text{ and } \pi_p((\begin{smallmatrix} x \\ dp \end{smallmatrix}))= (\begin{smallmatrix} z \\ d \end{smallmatrix}), $$ where $z$ is the remainder of $x$ divided by $d$. I guess that $w_p$ gives rise to a bijection between $S_1$ and $S_2$.
I have two questions:
Q1. Are the above formulas correct? If not, what are the correct ones?
Q2. What is the explicit description of $w_p$? In other words, what are $$ w_p((\begin{smallmatrix} x \\ d \end{smallmatrix})) ~\text{ and }~ w_p((\begin{smallmatrix} x \\ dp \end{smallmatrix}))? $$
So far, I have tried to compute them using $\pi_1 \circ w_p=\pi_p$, but I failed. I hope someone can help me to understand this problem.