Terrible Logic solution