closest pair structure code