Please ensure that the mouse and keyboard have fresh batteries.
If they are Apple wireless devices, use the USB>Lightning cable to your Mac or a wall charger. If recharging, give each about 30 minutes to charge then try again to connect.
If these devices have been used with another Mac prior, ensure that they have been properly paired with your computer.
See > Set up your Magic Keyboard, Magic Mouse...with your Mac - Apple Support
You should probably invest in an inexpensive wired USB keyboard and mouse for occasions like this when troubleshooting is required.