From the Super Mario Wiki
The game begins with two Boos inside a castle, and Mario standing between them. The objective of this microgame is to tap the arrow buttons to turn Mario and watch both Boos, and thus make them stop floating towards his direction. If Mario isn't touched by a Boo until the game ends, the player wins. If Mario is touched by a Boo, the game ends and the player will lose a life.