Cap-Exempt H1 Expiry

H1 picked in lottery in 2015. Worked in US between 2015 and 2019 ,until H1 Extension got Denied in 2019.
For how long am I eligible to apply for H1 without being subject to Cap? Should it be within 6 years from the date of return from US?
If I get admitted on F1 for Master’s, can the 3 years pending on H1 be utilized after 3 years OPT?

6 years from the date of expiration of the last valid H1