Conflict when transition from OPT to F1

I am currently on OPT and woking for a company in Virginia, OPT will expire on Aug 1st. The company also agrees to sponsor for my H1B For FY2018 H1B. However, if I fail the lottery, I still want to stay in the US to wait for the FY 2019 H1B. Thus, after my OPT expires on Aug 1st, I want to attend a community college in my area to maintain my F1 status. However, if I get picked in the lottery, my status will be changing from F1 OPT to H1B, at the same time, It will also be changed from F1 OPT back to F1. Will that create a conflict in USCIS system thus, making it illegal?

Thanks for the answer.

Your status will change from F1 to H1B on Oct 1st 2017 only when your H1b petition gets approved not when picked up in the lottery. If H1 not approved by Oct 1st 2017, you will be out of status from Oct 1st 2017, as cap-gap (you can file that with your univ international office once you get the receipt notice) will make sure you are on F1 and continue working until Oct 1st 2017 but not after that without H1 approval.

In case you receive H1B denial notice by Aug 1st. Your F1 status will end as of Aug 1st and you would move into grace period.