Section 17. Whoever keeps a building or room, or any part thereof, or occupies, or is found in, any place, way, public or private, park or parkway, or any open space, public or private, or any portion thereof, with apparatus, books or any device, for registering bets, or buying or selling pools, upon the result of a trial or contest of skill, speed or endurance of man, beast, bird or machine, or upon the result of a game, competition, political nomination, appointment or election, or whoever is present in such place, way, park or parkway, or any such open space, or any portion thereof, engaged in such business or employment; or, being such keeper, occupant, person found or person present, as aforesaid, registers such bets, or buys or sells such pools, or is concerned in buying or selling the same; or, being the owner, lessee or occupant of a building or room, or part thereof, or private grounds, knowingly permits the same to be used or occupied for any such purpose, or therein keeps, exhibits, uses or employs, or knowingly permits to be therein kept, exhibited, used or employed, any device or apparatus for registering such bets, or for buying or selling such pools, or whoever becomes the custodian or depository for hire, reward, commission or compensation in any manner, of any pools, money, property or thing of value, in any manner staked or bet upon such result, shall be punished by a fine of not more than three thousand dollars or by imprisonment in the state prison for not more than three years, or in jail or the house of correction for not more than two and one half years. This section shall not apply to a person who organizes, supervises, manages or finances another person for the purpose of gaming conducted in accordance with chapter 23K.