You have to file H1 application before your F1 expire. Then you can legally stay during H1 pending. But as soon as H1 deny, you will be out of staus.