Optimal thermometers with spin networks