Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Reference texts. R. C. Hibbeler, Structural Analysis, 10th ed. (Ch. 6 influence lines, Ch. 9 virtual work and Castigliano's theorems, Ch. 10 force method, Ch. 11 slope-deflection, Ch. 12 moment distribution, Ch. 16 stiffness method for frames); A. Kassimali, Structural Analysis, 6th ed.; A. Ghali, A. M. Neville & T. G. Brown, Structural Analysis: A Unified Classical and Matrix Approach, 7th ed.; J. C. McCormac, Structural Analysis: Using Classical and Matrix Methods, 4th ed. Canadian design context for the same structures: CSA S16, CSA A23.3 and the National Building Code of Canada 2020.
Sign convention used throughout. Member-end moments follow the counter-clockwise-positive slope-deflection form $M_{ij}=\dfrac{2EI}{L}\left(2\theta_i+\theta_j-3\psi_{ij}\right)+\mathrm{FEM}_{ij}$, with the chord rotation $\psi_{ij}=\left[(\mathbf{D}_j-\mathbf{D}_i)\cdot \mathbf{e}_2\right]/L$ and $\mathbf{e}_2$ the member axis turned $+90^\circ$. For a downward uniformly distributed load on a horizontal member, $\mathrm{FEM}_{ij}=+wL^{2}/12$ and $\mathrm{FEM}_{ji}=-wL^{2}/12$. Sagging moments are recovered as $M_{\text{sag}}(i)=-M_{ij}$ and $M_{\text{sag}}(j)=+M_{ji}$, and every bending-moment diagram is plotted on the tension side of the member.