Pseudorapidity distributions of charged hadrons in proton-lead collisions at \( \sqrt{s_{\mathrm{NN}}}=5.02 \) and 8.16 TeV