(1) First, evaluate how often you have broken your fasting by masturbation and make qaza fasting of those days. If you have broken some fasts by drinking and eating intentionally then you have to make qaza as well as kaffarah. In kaffarah, you have to keep fast of sixty days continuously without a gap.
(2) Likewise, in salah as well, estimate as much salah as you missed, then start making qaza with an intention that I am making qaza of my first missed Zuhr salah or Asr salah. There is no need to say: qaza No. 1265.
(3) If you kept on striving your level best to make up the missed salahs and fasts; and meanwhile you passed away leaving a will while you had to make up some of salah and fast then it is hoped that Allah will forgive you by His mercy.
Allah (Subhana Wa Ta’ala) knows Best
Darul Uloom Deoband