Magical cave is full of salt and treasure. You can take as much salt as you want but you cannot touch the treasures as something horrible will happen if you…